From be6de957e029476039bfc07eb08eba00562e1874 Mon Sep 17 00:00:00 2001 From: Fons Rademakers <Fons.Rademakers@cern.ch> Date: Wed, 22 Jan 2003 11:23:05 +0000 Subject: [PATCH] big patch adding full freetype 2 TTF support to the ROOT core and X11 and Win32gdk displaying modules. TTF support provided by Olivier Couet and Bertrand Bellenot (for Win32), build system updated by me. Also fixes the RH8.0 installation problems of rootd and proofd. git-svn-id: http://root.cern.ch/svn/root/trunk@5959 27541ba8-7e3a-0410-8455-c3a389f83636 --- Makefile | 30 +- README/INSTALL | 30 - base/src/TApplication.cxx | 23 +- base/src/TAttText.cxx | 10 +- build/package/common/root-bin.files | 1 + build/package/debian/root-bin.control.in | 2 +- build/package/lib/makedebdir.sh | 8 +- build/package/lib/makerpmspec.sh | 7 +- build/package/rpm/head.spec.in | 5 +- build/unix/makedist.sh | 4 +- build/win/makedist.sh | 4 +- cint/tool/ifdef/setup.bat | 8 +- config/Makefile.aix | 2 +- config/Makefile.aix5 | 2 +- config/Makefile.in | 6 +- config/Makefile.sgicc | 1 + config/Makefile.win32gdk | 2 + config/config.in | 7 +- config/rootrc.in | 3 +- configure | 109 +- etc/.cvsignore | 1 - graf/Module.mk | 27 +- graf/inc/LinkDef1.h | 3 +- graf/inc/LinkDef2.h | 4 +- graf/inc/TLatex.h | 5 +- graf/inc/TText.h | 68 +- graf/src/TLatex.cxx | 497 +------- graf/src/TText.cxx | 383 +++--- gui/src/TGApplication.cxx | 6 +- proofd/src/proofd.cxx | 6 +- rint/src/TRint.cxx | 20 +- rootd/src/rootd.cxx | 6 +- win32gdk/inc/GdkConstants.h | 3 + win32gdk/inc/TGWin32.h | 22 +- win32gdk/src/GdkThread.cxx | 13 +- win32gdk/src/TGWin32.cxx | 756 +++++++----- winnt/src/TWinNTSystem.cxx | 33 +- x11/src/TGX11.cxx | 24 +- x11ttf/Module.mk | 13 +- x11ttf/inc/TGX11TTF.h | 90 +- x11ttf/src/TGX11TTF.cxx | 1425 ++++------------------ 41 files changed, 1228 insertions(+), 2441 deletions(-) diff --git a/Makefile b/Makefile index d91143641ea..4af3e1a4218 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,9 @@ ifeq ($(findstring $(MAKECMDGOALS), maintainer-clean debian redhat),) include config/Makefile.config endif +ifeq ($(MAKECMDGOALS),clean) +include config/Makefile.config +endif ##### Include machine dependent macros ##### ##### However, if we are building packages or cleaning, we ##### @@ -20,6 +23,9 @@ endif ifeq ($(findstring $(MAKECMDGOALS), maintainer-clean debian redhat),) include config/Makefile.$(ARCH) endif +ifeq ($(MAKECMDGOALS),clean) +include config/Makefile.$(ARCH) +endif ##### Allow local macros ##### @@ -28,7 +34,7 @@ endif ##### Modules to build ##### MODULES = build cint utils base cont meta net zip clib matrix newdelete \ - hist tree graf g3d gpad gui minuit histpainter proof \ + hist tree freetype graf g3d gpad gui minuit histpainter proof \ treeplayer treeviewer physics postscript rint html eg mc \ geom geompainter @@ -38,20 +44,15 @@ SYSTEMO = $(WINNTO) SYSTEMDO = $(WINNTDO) else ifeq ($(ARCH),win32gdk) -MODULES += winnt win32gdk gl +MODULES += winnt win32gdk win32ttf gl SYSTEMO = $(WINNTO) SYSTEMDO = $(WINNTDO) else -MODULES += unix x11 x3d rootx rootd proofd +MODULES += unix x11 x11ttf x3d rootx rootd proofd SYSTEMO = $(UNIXO) SYSTEMDO = $(UNIXDO) endif endif -ifneq ($(TTFINCDIR),) -ifneq ($(TTFLIB),) -MODULES += x11ttf -endif -endif ifneq ($(OPENGLINCDIR),) ifneq ($(OPENGLULIB),) ifneq ($(OPENGLLIB),) @@ -128,9 +129,9 @@ MODULES += hbook endif ifneq ($(findstring $(MAKECMDGOALS),distclean maintainer-clean),) -MODULES += unix winnt x11 x11ttf win32 win32gdk gl rfio thread pythia \ - pythia6 venus table mysql pgsql sapdb srputils x3d rootx \ - rootd proofd dcache chirp hbook alien asimage ldap +MODULES += unix winnt x11 x11ttf win32 win32gdk win32ttf gl rfio thread \ + pythia pythia6 venus table mysql pgsql sapdb srputils x3d \ + rootx rootd proofd dcache chirp hbook alien asimage ldap MODULES := $(sort $(MODULES)) # removes duplicates endif @@ -487,6 +488,9 @@ install: echo "Installing icons in $(DESTDIR)$(ICONPATH)"; \ $(INSTALLDIR) $(DESTDIR)$(ICONPATH); \ $(INSTALLDATA) icons/*.xpm $(DESTDIR)$(ICONPATH); \ + echo "Installing fonts in $(DESTDIR)$(TTFFONTDIR)"; \ + $(INSTALLDIR) $(DESTDIR)$(TTFFONTDIR); \ + $(INSTALLDATA) fonts/* $(DESTDIR)$(TTFFONTDIR); \ echo "Installing misc docs in $(DESTDIR)$(DOCDIR)" ; \ $(INSTALLDIR) $(DESTDIR)$(DOCDIR); \ $(INSTALLDATA) LICENSE $(DESTDIR)$(DOCDIR); \ @@ -571,6 +575,7 @@ uninstall: test "x`ls $(DESTDIR)$(ICONPATH)`" = "x" ; then \ rm -rf $(DESTDIR)$(ICONPATH); \ fi ; \ + rm -rf $(DESTDIR)$(TTFFONTDIR); \ rm -rf $(DESTDIR)$(TUTDIR); \ rm -rf $(DESTDIR)$(TESTDIR); \ rm -rf $(DESTDIR)$(DOCDIR); \ @@ -636,9 +641,6 @@ showbuild: @echo "TABLE = $(TABLE)" @echo "XPMLIBDIR = $(XPMLIBDIR)" @echo "XPMLIB = $(XPMLIB)" - @echo "TTFLIBDIR = $(TTFLIBDIR)" - @echo "TTFLIB = $(TTFLIB)" - @echo "TTFINCDIR = $(TTFINCDIR)" @echo "TTFFONTDIR = $(TTFFONTDIR)" @echo "OPENGLLIBDIR = $(OPENGLLIBDIR)" @echo "OPENGLULIB = $(OPENGLULIB)" diff --git a/README/INSTALL b/README/INSTALL index 33a097f6f65..ff808b844a6 100644 --- a/README/INSTALL +++ b/README/INSTALL @@ -332,8 +332,6 @@ For example: export CERNLIB=~/cernlib # must contain libpacklib.a libkernlib.a export RFIO=~/shift/lib # CERN's SHIFT library, must # contain libshift.a - export TTF=~/ttf # must contain fonts/ (and possibly - # include/ lib/) export OPENGL=~/Mesa # must contain include/ lib/ export SRP=~/src/srp # must contain include/ lib/ #export AFS= # must contain include/ lib/ @@ -401,10 +399,6 @@ The flags consist of two classes: options is strongly recommended. This requires the system library libpthread (Posix threads). Default is false, except for the "linux" architecture. - * ttf - True Type Font support for those OSs with no native TTF - support. This feature requires third-party library libtff, header - files and True Type fonts. Default is true. * opengl OpenGL (3D rendering and visualisation) support. This is especially powerful if you have a 3D accelerated card and a @@ -484,13 +478,6 @@ The flags consist of two classes: to any feature, but provides you with way of getting the TBrowser and others to look for additional icons in some system-wide directory. - * ttf-incdir - Directory containing freetype.h, needed by feature ttf. - * ttf-libdir - Directory containing libttf.{so,a}, needed by feature ttf. - * ttf-fontdir - Directory containing TTF font files, needed by feature ttf. - "configure" is looking for "arial.ttf". * opengl-incdir Directory containing GL/gl.h (note the sub-directory), needed by feature opengl. @@ -570,23 +557,6 @@ the case for any Un*x OS. For architecture "linux" thread support will always be build. -True Type Font library and fonts --------------------------------- -On how to get the True Type ttf directory see: - - http://root.cern.ch/root/TrueType.html - -For prebuilt versions see: - - ftp://root.cern.ch/root/ttf/ - -Most Linux distributions have a freetype package with the needed -library and headers, but seldomly do they provide the fonts. You can -get a minimal set of fonts from: - - ftp://root.cern.ch/root/ttf/ttf_fonts.tar.gz - - OpenGL library -------------- On how to get an open source version of OpenGL see: diff --git a/base/src/TApplication.cxx b/base/src/TApplication.cxx index bb38b97f46e..40a583aa5ac 100644 --- a/base/src/TApplication.cxx +++ b/base/src/TApplication.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TApplication.cxx,v 1.42 2002/12/10 19:51:47 brun Exp $ +// @(#)root/base:$Name: $:$Id: TApplication.cxx,v 1.43 2002/12/11 15:16:33 brun Exp $ // Author: Fons Rademakers 22/12/95 /************************************************************************* @@ -155,19 +155,24 @@ TApplication::TApplication(const char *appClassName, // Try to load TrueType font renderer. Only try to load if not in batch // mode and Root.UseTTFonts is true and Root.TTFontPath exists. Abort silently // if libttf or libGX11TTF are not found in $ROOTSYS/lib or $ROOTSYS/ttf/lib. -#ifndef R__WIN32 +#if !defined(R__WIN32) || defined(GDK_WIN32) if (strcmp(appClassName, "proofserv")) { const char *ttpath = gEnv->GetValue("Root.TTFontPath", # ifdef TTFFONTDIR TTFFONTDIR); # else - "$(HOME)/ttf/fonts"); + "$(ROOTSYS)/fonts"); # endif char *ttfont = gSystem->Which(ttpath, "arialbd.ttf", kReadPermission); if (!gROOT->IsBatch() && ttfont && gEnv->GetValue("Root.UseTTFonts", 1)) { +#if defined(GDK_WIN32) + TString plugin = "win32ttf"; +#else + TString plugin = "x11ttf"; +#endif TPluginHandler *h; - if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualX", "x11ttf"))) + if ((h = gROOT->GetPluginManager()->FindHandler("TVirtualX", plugin))) h->LoadPlugin(); } @@ -266,7 +271,7 @@ void TApplication::GetOptions(int *argc, char **argv) gROOT->SetBatch(); if (gGuiFactory != gBatchGuiFactory) delete gGuiFactory; gGuiFactory = gBatchGuiFactory; -#ifndef WIN32 +#ifndef R__WIN32 if (gVirtualX != gGXBatch) delete gVirtualX; #endif gVirtualX = gGXBatch; @@ -274,7 +279,7 @@ void TApplication::GetOptions(int *argc, char **argv) #if 0 } else if (!strcmp(argv[i], "-x")) { // remote ROOT display server not operational yet -#ifndef WIN32 +#ifndef R__WIN32 if (gVirtualX != gGXBatch) delete gVirtualX; #endif gVirtualX = new TGXClient("Root_Client"); @@ -602,7 +607,7 @@ void TApplication::ProcessLine(const char *line, Bool_t sync, int *err) TString arguments; TString io; TString fname = gSystem->SplitAclicMode(line+3, aclicMode, arguments, io); - + char *mac = gSystem->Which(TROOT::GetMacroPath(), fname, kReadPermission); if (arguments.Length()) { Warning("ProcessLine", "argument(s) \"%s\" ignored with .%c", arguments.Data(), @@ -660,7 +665,7 @@ void TApplication::ProcessFile(const char *name, int *error) Int_t nch = strlen(name); if (nch == 0) return; - + TString aclicMode; TString arguments; TString io; @@ -731,7 +736,7 @@ void TApplication::ProcessFile(const char *name, int *error) file.close(); if (!execute) { - TString exname = exnam; + TString exname = exnam; if (!tempfile) { // We have a script that does NOT contain an unamed macro, // so we can call the script compiler on it. diff --git a/base/src/TAttText.cxx b/base/src/TAttText.cxx index 21495a9a535..c3bfb37e86a 100644 --- a/base/src/TAttText.cxx +++ b/base/src/TAttText.cxx @@ -1,4 +1,4 @@ -// @(#)root/base:$Name: $:$Id: TAttText.cxx,v 1.12 2002/05/03 10:48:53 brun Exp $ +// @(#)root/base:$Name: $:$Id: TAttText.cxx,v 1.13 2002/09/14 11:12:47 brun Exp $ // Author: Rene Brun 12/12/94 /************************************************************************* @@ -175,15 +175,7 @@ void TAttText::Modify() #ifndef WIN32 again: -#ifndef R__TTFROT - if (gVirtualX->HasTTFonts() && gVirtualX->GetTextSize() != -10.0) { - if (fTextAngle != 0) { - gVirtualX->SetTextSize(-10.0); - goto again; - } -#else if (gVirtualX->HasTTFonts()) { -#endif if (gVirtualX->GetTextFont() != fTextFont) { gVirtualX->SetTextFont(fTextFont); if (!gVirtualX->HasTTFonts()) goto again; diff --git a/build/package/common/root-bin.files b/build/package/common/root-bin.files index e724920bb8d..f480b727028 100644 --- a/build/package/common/root-bin.files +++ b/build/package/common/root-bin.files @@ -1,5 +1,6 @@ @prefix@/bin/* @prefix@/share/man/man1/* +@prefix@/share/root/fonts @prefix@/share/root/icons @prefix@/share/root/macros @prefix@/share/emacs/site-lisp/root-help.el diff --git a/build/package/debian/root-bin.control.in b/build/package/debian/root-bin.control.in index a0f98b772c3..4b55c8a1a41 100644 --- a/build/package/debian/root-bin.control.in +++ b/build/package/debian/root-bin.control.in @@ -2,6 +2,6 @@ Package: root-bin Architecture: any Depends: ${shlibs:Depends} Recommends: libc6-dev, libstdc++-dev, libroot-dev -Suggests: root-gl, root-ttf, root-zebra +Suggests: root-gl, root-zebra Description: @short@ @long@ diff --git a/build/package/lib/makedebdir.sh b/build/package/lib/makedebdir.sh index af64e676d3c..364a2cc6447 100755 --- a/build/package/lib/makedebdir.sh +++ b/build/package/lib/makedebdir.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $Id: makedebdir.sh,v 1.5 2002/05/27 16:27:56 rdm Exp $ +# $Id: makedebdir.sh,v 1.6 2002/07/31 20:45:10 rdm Exp $ # # Make the debian packaging directory # @@ -18,7 +18,7 @@ etcdir=etc/root docdir=${prefix}/share/doc/root-doc ### echo %%% Packages ordered by preference -pkgs="root-daemon root-ttf root-zebra root-gl root-mysql root-pgsql root-table root-shift root-cint root-bin libroot-dev libroot" +pkgs="root-daemon root-zebra root-gl root-mysql root-pgsql root-table root-shift root-cint root-bin libroot-dev libroot" pkgs=`./configure linuxdeb --pkglist --enable-soversion --enable-table --enable-thread --enable-shared | sed -n 's,packages: ,,p'` ### echo %%% Package list is: $pkgs lvls="preinst postinst prerm postrm" @@ -74,7 +74,6 @@ for i in $pkgs; do root-mysql) bd="${bd}, libmysqlclient-dev" ;; root-pgsql) bd="${bd}, postgresql-dev" ;; root-pythia) bd="${bd}, libpythia-dev" ;; - root-ttf) bd="${bd}, freetype2-dev" ;; *) ;; esac done @@ -130,6 +129,9 @@ chmod 755 ${tgtdir}/rules # # $Log: makedebdir.sh,v $ +# Revision 1.6 2002/07/31 20:45:10 rdm +# modified files for Debian and RedHat packaging. By Christian Holm. +# # Revision 1.5 2002/05/27 16:27:56 rdm # rename libStar to libTable. # diff --git a/build/package/lib/makerpmspec.sh b/build/package/lib/makerpmspec.sh index 3aa1e1125d0..e941bd982cd 100755 --- a/build/package/lib/makerpmspec.sh +++ b/build/package/lib/makerpmspec.sh @@ -1,6 +1,6 @@ #!/bin/sh -e # -# $Id: makerpmspec.sh,v 1.4 2002/05/27 16:27:56 rdm Exp $ +# $Id: makerpmspec.sh,v 1.5 2002/07/31 20:45:10 rdm Exp $ # # Make the rpm spec file in ../root.spec # @@ -15,7 +15,7 @@ tgtdir=rpm curdir=`pwd` ### echo %%% Packages ordered by preference -pkgs="root-daemon root-ttf root-zebra root-gl root-mysql root-pgsql root-table root-shift root-cint root-bin libroot-dev libroot" +pkgs="root-daemon root-zebra root-gl root-mysql root-pgsql root-table root-shift root-cint root-bin libroot-dev libroot" pkgs=`./configure linux --pkglist --enable-soversion --enable-table --enable-thread --enable-shared | sed -n 's,packages: ,,p'` # ROOT version @@ -70,6 +70,9 @@ sed -e "s|@libdir@|${libdir}|" \ # # $Log: makerpmspec.sh,v $ +# Revision 1.5 2002/07/31 20:45:10 rdm +# modified files for Debian and RedHat packaging. By Christian Holm. +# # Revision 1.4 2002/05/27 16:27:56 rdm # rename libStar to libTable. # diff --git a/build/package/rpm/head.spec.in b/build/package/rpm/head.spec.in index dd96213608c..68b73a30bca 100644 --- a/build/package/rpm/head.spec.in +++ b/build/package/rpm/head.spec.in @@ -43,10 +43,9 @@ See root-bin documentation # which they should be specified: # # root-daemon \ -# root-ttf | # root-zebra | -# root-opengl + Feature packages -# root-mysql | +# root-opengl | +# root-mysql + Feature packages # root-pythia | # root-star | # root-shift / diff --git a/build/unix/makedist.sh b/build/unix/makedist.sh index df668171de8..4e3bc097c47 100755 --- a/build/unix/makedist.sh +++ b/build/unix/makedist.sh @@ -33,8 +33,8 @@ $TAR $TARFILE $EXCLUDE $dir/LICENSE $dir/README $dir/bin \ $dir/include $dir/lib $dir/cint/MAKEINFO $dir/cint/include \ $dir/cint/lib $dir/cint/stl $dir/tutorials/*.cxx $dir/tutorials/*.C \ $dir/tutorials/*.h $dir/tutorials/*.dat $dir/test/*.cxx $dir/test/*.h \ - $dir/test/Makefile* $dir/test/README $dir/macros $dir/icons $dir/etc \ - $dir/proof/etc $dir/proof/utils + $dir/test/Makefile* $dir/test/README $dir/macros $dir/icons $dir/fonts \ + $dir/etc $dir/proof/etc $dir/proof/utils if [ "$TAR" = '' ] || [ $stat = 0 ]; then gzip $TARFILE fi diff --git a/build/win/makedist.sh b/build/win/makedist.sh index 7eb33b8abc1..9624d741729 100755 --- a/build/win/makedist.sh +++ b/build/win/makedist.sh @@ -34,8 +34,8 @@ $TAR $TARFILE $EXCLUDE $dir/LICENSE $dir/README $dir/bin \ $dir/include $dir/lib $dir/cint/MAKEINFO $dir/cint/include \ $dir/cint/lib $dir/cint/stl $dir/tutorials/*.cxx $dir/tutorials/*.C \ $dir/tutorials/*.h $dir/tutorials/*.dat $dir/test/*.cxx $dir/test/*.h \ - $dir/test/Makefile* $dir/test/README $dir/macros $dir/icons $dir/etc \ - $dir/proof/etc $dir/proof/utils + $dir/test/Makefile* $dir/test/README $dir/macros $dir/icons $dir/fonts \ + $dir/etc $dir/proof/etc $dir/proof/utils if [ "$TAR" = '' ] || [ $stat = 0 ]; then gzip $TARFILE fi diff --git a/cint/tool/ifdef/setup.bat b/cint/tool/ifdef/setup.bat index e84c20d0b3f..d188b7c18ab 100644 --- a/cint/tool/ifdef/setup.bat +++ b/cint/tool/ifdef/setup.bat @@ -1,4 +1,4 @@ - -nmake -f ifdef.mak -move ifdef.exe %CINTSYSDIR%\ifdef.exe -nmake -f ifdef.mak clean + +nmake -f ifdef.mak +move ifdef.exe %CINTSYSDIR%\ifdef.exe +nmake -f ifdef.mak clean diff --git a/config/Makefile.aix b/config/Makefile.aix index ce6fafdbfd0..85a13715b12 100644 --- a/config/Makefile.aix +++ b/config/Makefile.aix @@ -78,7 +78,7 @@ PYTHIA6LIBEXTRA = -lEG -lGraf $(FPYTHIA6LIBDIR) $(FPYTHIA6LIB) VENUSLIBDEP = $(EGLIB) VENUSLIBEXTRA = -lEG $(FVENUSLIBDIR) $(FVENUSLIB) X11TTFLIBDEP = $(X11LIB) -X11TTFLIBEXTRA = -lGX11 -L$(TTFLIBDIR) -lttf -lX11 +X11TTFLIBEXTRA = -lGX11 -lX11 TABLELIBDEP = $(TREELIB) $(GPADLIB) $(G3DLIB) $(GRAFLIB) $(HISTLIB) TABLELIBEXTRA = -lTree -lGpad -lGraf3d -lGraf -lHist GLLIBDEP = $(GPADLIB) $(G3DLIB) $(GUILIB) diff --git a/config/Makefile.aix5 b/config/Makefile.aix5 index 065baa1a05f..d7e0510d7b9 100644 --- a/config/Makefile.aix5 +++ b/config/Makefile.aix5 @@ -78,7 +78,7 @@ PYTHIA6LIBEXTRA = -lEG -lGraf $(FPYTHIA6LIBDIR) $(FPYTHIA6LIB) VENUSLIBDEP = $(EGLIB) VENUSLIBEXTRA = -lEG $(FVENUSLIBDIR) $(FVENUSLIB) X11TTFLIBDEP = $(X11LIB) -X11TTFLIBEXTRA = -lGX11 -L$(TTFLIBDIR) -lttf -lX11 +X11TTFLIBEXTRA = -lGX11 -lX11 TABLELIBDEP = $(TREELIB) $(GPADLIB) $(G3DLIB) $(GRAFLIB) $(HISTLIB) TABLELIBEXTRA = -lTree -lGpad -lGraf3d -lGraf -lHist GLLIBDEP = $(GPADLIB) $(G3DLIB) $(GUILIB) diff --git a/config/Makefile.in b/config/Makefile.in index 4970d4cf5e9..7068ec598bd 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -18,6 +18,7 @@ ETCDIR := @etcdir@ MANDIR := @mandir@ DATADIR := @datadir@ ELISPDIR := @elispdir@ +TTFFONTDIR := @ttffontdir@ PROOFDATADIR := @proofdir@ MACRODIR := @macrodir@ SRCDIR := @srcdir@ @@ -37,11 +38,6 @@ ENABLETHREAD := @enable_thread@ OSTHREADLIBDIR := @threadlibdir@ OSTHREADLIB := @threadlib@ -TTFLIBDIR := @ttflibdir@ -TTFFONTDIR := @ttffontdir@ -TTFINCDIR := @ttfincdir@ -TTFLIB := @ttflib@ - OPENGLLIBDIR := @opengllibdir@ OPENGLULIB := @openglulib@ OPENGLLIB := @opengllib@ diff --git a/config/Makefile.sgicc b/config/Makefile.sgicc index 702d91686f4..436940818ed 100644 --- a/config/Makefile.sgicc +++ b/config/Makefile.sgicc @@ -43,6 +43,7 @@ F77LIBS = -lftn else F77LIBS = -lI77 -lU77 -lF77 -lisam endif + # Extras GLLIBEXTRA = $(OPENGLLIBDIR) $(OPENGLULIB) $(OPENGLLIB) diff --git a/config/Makefile.win32gdk b/config/Makefile.win32gdk index faba6e6e9ea..ad4b0c6226d 100644 --- a/config/Makefile.win32gdk +++ b/config/Makefile.win32gdk @@ -70,6 +70,8 @@ G3DLIBDEP = $(GRAFLIB) $(HISTLIB) G3DLIBEXTRA = lib/libGraf.lib lib/libHist.lib WIN32GDKLIBDEP = $(GPADLIB) $(GRAFLIB) $(GDKDLLS) $(GDKLIBS) WIN32GDKLIBEXTRA = lib/libGpad.lib lib/libGraf.lib $(GDKLIBS) +WIN32TTFLIBDEP = $(WIN32GDKLIB) $(GRAFLIB) +WIN32TTFLIBEXTRA = lib/libGraf.lib lib/libWin32gdk.lib GUILIBDEP = $(GPADLIB) $(GRAFLIB) GUILIBEXTRA = lib/libGpad.lib lib/libGraf.lib HISTPAINTERLIBDEP = $(GRAFLIB) $(HISTLIB) $(MATRIXLIB) diff --git a/config/config.in b/config/config.in index 0d04776cf21..877bd4041c5 100644 --- a/config/config.in +++ b/config/config.in @@ -1,7 +1,5 @@ /* Configrations file for @architecture@ */ -#ifndef HAVE_CONFIG -#error Trying to use config.h, though HAVE_CONFIG is undefined -#endif +#ifdef HAVE_CONFIG #define ROOTPREFIX "@prefix@" #define ROOTBINDIR "@bindir@" #define ROOTLIBDIR "@libdir@" @@ -14,3 +12,6 @@ #define EXTRAICONPATH "@extraiconpath@" #define TTFFONTDIR "@ttffontdir@" #define CINTINCDIR "@cintincdir@" +#endif + +#@setresuid@ HAS_SETRESUID /**/ diff --git a/config/rootrc.in b/config/rootrc.in index 55302cfce83..d8cfa12b410 100644 --- a/config/rootrc.in +++ b/config/rootrc.in @@ -1,4 +1,4 @@ -# @(#)root/config:$Name: $:$Id: rootrc.in,v 1.39 2003/01/16 18:46:09 brun Exp $ +# @(#)root/config:$Name: $:$Id: rootrc.in,v 1.40 2003/01/17 17:48:56 brun Exp $ # Author: Fons Rademakers 22/09/95 # ROOT Environment settings are handled via the class TEnv. To see @@ -163,6 +163,7 @@ Plugin.TVirtualX: x11 TGX11 GX11 "TGX11(const char*,con +Plugin.TVirtualX: x11ttf TGX11TTF GX11TTF "TGX11TTF()" +Plugin.TVirtualX: win32 TGWin32 Win32 "TGWin32(const char*,const char*)" +Plugin.TVirtualX: win32gdk TGWin32 Win32gdk "TGWin32(const char*,const char*)" ++Plugin.TVirtualX: win32ttf TGWin32TTF GWin32TTF "TGWin32TTF()" Plugin.TGuiFactory: root TRootGuiFactory Gui "TRootGuiFactory()" +Plugin.TGuiFactory: win32 TWin32GuiFactory Win32 "TWin32GuiFactory()" diff --git a/configure b/configure index bdf17208437..6d3fb6ed780 100755 --- a/configure +++ b/configure @@ -42,7 +42,6 @@ enable_soversion=no enable_srp=yes enable_table=no enable_thread= # must be set explicitely via --enable-thread -enable_ttf=yes enable_venus=yes enable_exceptions=yes show_pkglist=no @@ -50,7 +49,7 @@ show_pkglist=no options="enable_afs enable_cern enable_mysql enable_opengl enable_pgsql \ enable_pythia enable_pythia6 enable_rfio enable_dcache enable_rpath \ enable_sapdb enable_shadowpw enable_shared enable_soversion \ - enable_srp enable_table enable_thread enable_ttf enable_venus \ + enable_srp enable_table enable_thread enable_venus \ enable_krb5 enable_ldap enable_exceptions enable_openiv enable_alien \ enable_asimage enable_chirp" @@ -341,6 +340,7 @@ Usage: $0 <architecture> [flag=value] --docdir Documentation (<prefix>/share/doc/root) --etcdir Config installation dir (/etc/root) --elispdir Where to put Emacs Lisp (<prefix>/share/emacs/site-lisp) + --fontdir Font installation dir (<datadir>/fonts) --iconpath Icon installation dir (<datadir>/icons) --incdir Header installation dir (<prefix>/include/root) --libdir Library installation dir (<prefix>/lib/root) @@ -376,7 +376,6 @@ enable/disable options, prefix with either --enable- or --disable- srp SRP support, requires SRP source tree table Build libTable contrib library thread Thread support - ttf True Type Font support, requires libtff venus Venus EG support, requires libVenus with options, prefix with --with-, enables corresponding support afs AFS support, location of AFS distribution @@ -410,9 +409,6 @@ with options, prefix with --with-, enables corresponding support srp-libdir SRP support, location header of libsrp.a sys-iconpath Extra icon path thread-libdir Thread support, path to libpthread - ttf-fontdir TTF support, location of TTF fonts - ttf-incdir TTF support, location of freetype.h - ttf-libdir TTF support, location of libttf venus-libdir VENUS support, location of libVenus xpm-libdir XPM support, path to libXpm @@ -507,9 +503,6 @@ if test $# -gt 0 ; then --with-srp=*) srpdir=$optarg ; enable_srp="yes" ;; --with-sys-iconpath=*) extraiconpath=$optarg ;; --with-thread-libdir=*) threadlibdir=$optarg ; enable_thread="yes" ;; - --with-ttf-fontdir=*) ttffontdir=$optarg ; enable_ttf="yes" ;; - --with-ttf-incdir=*) ttfincdir=$optarg ; enable_ttf="yes" ;; - --with-ttf-libdir=*) ttflibdir=$optarg ; enable_ttf="yes" ;; --with-venus-libdir=*) venuslibdir=$optarg ; enable_venus="yes" ;; --with-xpm-libdir=*) xpmlibdir=$optarg ;; ################################################################ @@ -668,54 +661,6 @@ if test "x$enable_thread" = "xyes" && test ! "$platform" = "win32" ; then fi fi -###################################################################### -# -### echo %%% FreeType Support - Third party libraries -# -# (see freetype.org) -# -if test ! "x$enable_ttf" = "xno" && test ! "$platform" = "win32"; then - # Check for FreeType TTF include, library and fonts - check_header "freetype.h" "$ttfincdir" $TTF $TTF/include \ - /usr/include /usr/local/include /usr/include/freetype \ - /usr/local/include/freetype /usr/freetype/include \ - /usr/local/freetype/include /usr/freetype \ - /usr/local/freetype /opt/freetype /opt/freetype/include \ - /usr/local/ttf/include /opt/ttf/include \ - /usr/include/freetype1/freetype - ttfinc=$found_hdr - ttfincdir=$found_dir - - check_library "libttf" "$enable_shared" "$ttflibdir" \ - $TTF $TTF/lib /usr/lib /usr/local/lib /usr/lib/freetype \ - /usr/local/lib/freetype /usr/freetype/lib \ - /usr/local/freetype/lib /usr/freetype \ - /usr/local/freetype /opt/freetype /opt/freetype/lib \ - /usr/local/ttf/lib /opt/ttf/lib - ttflib=$found_lib - ttflibdir=$found_dir - - check_header "arial.ttf" "$ttffontdir" $TTF $TTF/fonts /usr/lib/X11/fonts \ - /usr/lib/X11/fonts/ttf /usr/share /usr/share/fonts \ - /usr/share/fonts/ttf /usr/share/ttf /usr/local/share \ - /usr/local/share/fonts /usr/local/share/fonts/ttf \ - /usr/local/share/ttf /opt/fonts /opt/fonts/ttf \ - /opt/ttf /opt/ttf/fonts /usr/local/ttf/fonts \ - /usr/X11R6/lib/X11/fonts/truetype /usr/X11R6/lib/X11/fonts/TrueType - ttffontdir=$found_dir - - # Give up if none of the above found - # Note that we no longer require the actual fonts at compile time - # since they are strictlu not needed until run time; as long - # as the freetype library and headers are present we can compile - # libGX11TTF.so. Hence, individuals that do not particular want - # the Microsoft fonts (for whatever reason) can still build the - # library. - if test "x$ttflib" = "x" || test "x$ttfincdir" = "x" ; then - enable_ttf="no" - fi -fi - ###################################################################### # ### echo %%% OpenGL Support - Third party libraries @@ -1442,7 +1387,6 @@ else echo "no" fi - ###################################################################### # ### echo %%% Debian or Red Hat package list @@ -1453,7 +1397,6 @@ fi # if test "x$show_pkglist" = "xyes" ; then pkglist="root-daemon" - test "x$enable_ttf" = "xyes" && pkglist="$pkglist root-ttf" test "x$enable_cern" = "xyes" && pkglist="$pkglist root-zebra" if test "x$enable_openiv" = "xyes" ; then pkglist="$pkglist root-gliv" @@ -1474,6 +1417,22 @@ if test "x$show_pkglist" = "xyes" ; then exit 0 fi +###################################################################### +# +### echo %%% check for setresuid and setresgid +# +setresuid="undef" +case $arch in + linux*) + message "Checking whether setresuid declared in /usr/include/unistd.h" + if `grep setresuid /usr/include/unistd.h >/dev/null 2>&1` ; then + setresuid="define" + echo "yes" + else + echo "no" + fi ;; +esac + ###################################################################### # ### echo %%% Exit here if this is a dry run @@ -1551,7 +1510,7 @@ if test ! "x$haveconfig" = "x" ; then if test "x$cintincdir" = "x"; then cintincdir=$datadir/cint; fi if test "x$iconpath" = "x"; then iconpath=$datadir/icons; fi if test "x$srcdir" = "x"; then srcdir=$datadir/src; fi - if test "x$ttffontdir" = "x"; then ttffontdir=$datadir/fonts; fi + if test "x$fontdir" = "x"; then fontdir=$datadir/fonts; fi if test "x$docdir" = "x"; then docdir=$prefix/share/doc/root; fi if test "x$testdir" = "x"; then testdir=$docdir/test; fi if test "x$tutdir" = "x"; then tutdir=$docdir/tutorials; fi @@ -1590,6 +1549,7 @@ else cintincdir=\$\(ROOTSYS\)/cint iconpath=\$\(ROOTSYS\)/icons srcdir=\$\(ROOTSYS\)/src + fontdir=\$\(ROOTSYS\)/fonts docdir=\$\(ROOTSYS\) testdir=\$\(ROOTSYS\)/test tutdir=\$\(ROOTSYS\)/tutorials @@ -1699,10 +1659,7 @@ sed \ -e "s|@testdir@|$testdir|" \ -e "s|@threadlib@|$threadlib|" \ -e "s|@threadlibdir@|$threadlibdir|" \ - -e "s|@ttffontdir@|$ttffontdir|" \ - -e "s|@ttfincdir@|$ttfincdir|" \ - -e "s|@ttflib@|$ttflib|" \ - -e "s|@ttflibdir@|$ttflibdir|" \ + -e "s|@ttffontdir@|$fontdir|" \ -e "s|@tutdir@|$tutdir|" \ -e "s|@venuslib@|$venuslib|" \ -e "s|@venuslibdir@|$venuslibdir|" \ @@ -1738,7 +1695,8 @@ sed \ -e "s|@macrodir@|$macrodir|" \ -e "s|@prefix@|$prefix|" \ -e "s|@srcdir@|$srcdir|" \ - -e "s|@ttffontdir@|$ttffontdir|" \ + -e "s|@ttffontdir@|$fontdir|" \ + -e "s|@setresuid@|$setresuid|" \ < config.tmp > $CONFOUT rm -f config.tmp echo "done" @@ -1777,17 +1735,11 @@ echo "done" # etc/system.rootrc # message "Writing $ROOTRCOUT" -if test "$ttffontdir" = "$HOME/ttf" ; then - ttffontdir=\$\(HOME\)/ttf -fi -if test "$ttffontdir" = "$HOME/ttf/fonts" ; then - ttffontdir=\$\(HOME\)/ttf/fonts -fi sed -e "s|@libdir@|$libdir|" \ -e "s|@macrodir@|$macrodir|" \ -e "s|@bindir@|$bindir|" \ -e "s|@etcdir@|$etcdir|" \ - -e "s|@ttffontdir@|$ttffontdir|" \ + -e "s|@ttffontdir@|$fontdir|" \ -e "s|@iconpath@|$iconpath|" \ < rootrc.tmp > $ROOTRCOUT rm -f rootrc.tmp @@ -1854,17 +1806,8 @@ fi # Warning about recommended build options # echo "" -if test "x$enable_ttf" = "xno" || test "x$enable_opengl" = "xno" || \ - test "x$ttffontdir" = "x" ; then - if test "x$enable_ttf" = "xno" && test ! "x$platform" = "xwin32" ; then - echo "To build the ROOT TrueType font add-on library see README/INSTALL." - fi - if test "x$ttffontdir" = "x" ; then - echo "To use TTF fonts set the TTFontPath resource in your .rootrc file." - fi - if test "x$enable_opengl" = "xno" ; then - echo "To build the ROOT OpenGL add-on library see README/INSTALL." - fi +if test "x$enable_opengl" = "xno" ; then + echo "To build the ROOT OpenGL add-on library see README/INSTALL." echo "" echo "" fi diff --git a/etc/.cvsignore b/etc/.cvsignore index 7218ec277b3..135fd4692cd 100644 --- a/etc/.cvsignore +++ b/etc/.cvsignore @@ -1,3 +1,2 @@ system.rootrc root.mimes - diff --git a/graf/Module.mk b/graf/Module.mk index 1e11595afbc..c710621fae3 100644 --- a/graf/Module.mk +++ b/graf/Module.mk @@ -23,6 +23,9 @@ GRAFDO := $(GRAFDO1) $(GRAFDO2) GRAFDH := $(GRAFDS:.cxx=.h) GRAFH := $(filter-out $(MODDIRI)/LinkDef%,$(wildcard $(MODDIRI)/*.h)) +GRAFHD := $(filter-out $(MODDIRI)/TTF.h,$(GRAFH)) +GRAFHD := $(filter-out $(MODDIRI)/TText.h,$(GRAFHD)) +GRAFHD := $(filter-out $(MODDIRI)/TLatex.h,$(GRAFHD)) GRAFS := $(filter-out $(MODDIRS)/G__%,$(wildcard $(MODDIRS)/*.cxx)) GRAFO := $(GRAFS:.cxx=.o) @@ -41,22 +44,22 @@ INCLUDEFILES += $(GRAFDEP) include/%.h: $(GRAFDIRI)/%.h cp $< $@ -$(GRAFLIB): $(GRAFO) $(GRAFDO) $(MAINLIBS) $(GRAFLIBDEP) +$(GRAFLIB): $(GRAFO) $(GRAFDO) $(FREETYPELIB) $(MAINLIBS) $(GRAFLIBDEP) @$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" \ - "$(SOFLAGS)" libGraf.$(SOEXT) $@ "$(GRAFO) $(GRAFDO)" \ - "$(GRAFLIBEXTRA)" + "$(SOFLAGS)" libGraf.$(SOEXT) $@ \ + "$(GRAFO) $(GRAFDO)" "$(FREETYPELIB) $(GRAFLIBEXTRA)" -$(GRAFDS1): $(GRAFH) $(GRAFL1) $(ROOTCINTTMP) +$(GRAFDS1): $(GRAFHD) $(GRAFL1) $(ROOTCINTTMP) @echo "Generating dictionary $@..." - $(ROOTCINTTMP) -f $@ -c $(GRAFH) $(GRAFL1) + $(ROOTCINTTMP) -f $@ -c $(GRAFHD) $(GRAFL1) $(GRAFDS2): $(GRAFH) $(GRAFL2) $(ROOTCINTTMP) @echo "Generating dictionary $@..." $(ROOTCINTTMP) -f $@ -c $(GRAFH) $(GRAFL2) $(GRAFDO1): $(GRAFDS1) $(CXX) $(NOOPT) $(CXXFLAGS) -I. -o $@ -c $< -$(GRAFDO2): $(GRAFDS2) - $(CXX) $(NOOPT) $(CXXFLAGS) -I. -o $@ -c $< +$(GRAFDO2): $(GRAFDS2) $(FREETYPELIB) + $(CXX) $(NOOPT) $(CXXFLAGS) -I. -I$(FREETYPEDIRI) -o $@ -c $< all-graf: $(GRAFLIB) @@ -69,3 +72,13 @@ distclean-graf: clean-graf @rm -f $(GRAFDEP) $(GRAFDS) $(GRAFDH) $(GRAFLIB) distclean:: distclean-graf + +##### extra rules ###### +graf/src/TTF.o: graf/src/TTF.cxx $(FREETYPELIB) + $(CXX) $(OPT) $(CXXFLAGS) -I$(FREETYPEDIRI) -o $@ -c $< + +graf/src/TText.o: graf/src/TText.cxx $(FREETYPELIB) + $(CXX) $(OPT) $(CXXFLAGS) -I$(FREETYPEDIRI) -o $@ -c $< + +graf/src/TLatex.o: graf/src/TLatex.cxx $(FREETYPELIB) + $(CXX) $(OPT) $(CXXFLAGS) -I$(FREETYPEDIRI) -o $@ -c $< diff --git a/graf/inc/LinkDef1.h b/graf/inc/LinkDef1.h index 92cd977dc8a..5ffa69144bf 100644 --- a/graf/inc/LinkDef1.h +++ b/graf/inc/LinkDef1.h @@ -1,4 +1,4 @@ -/* @(#)root/graf:$Name: $:$Id: LinkDef1.h,v 1.5 2000/12/09 18:23:51 brun Exp $ */ +/* @(#)root/graf:$Name: $:$Id: LinkDef1.h,v 1.6 2002/08/09 20:45:43 brun Exp $ */ /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * @@ -38,7 +38,6 @@ #pragma link C++ class TPaveText-; #pragma link C++ class TPavesText+; #pragma link C++ class TPolyLine-; -#pragma link C++ class TText-; #pragma link C++ class TWbox+; #endif diff --git a/graf/inc/LinkDef2.h b/graf/inc/LinkDef2.h index 97e1ec256cc..3b5fec545b7 100644 --- a/graf/inc/LinkDef2.h +++ b/graf/inc/LinkDef2.h @@ -1,4 +1,4 @@ -/* @(#)root/graf:$Name: $:$Id: LinkDef2.h,v 1.3 2001/10/01 06:48:34 brun Exp $ */ +/* @(#)root/graf:$Name: $:$Id: LinkDef2.h,v 1.4 2002/08/09 13:56:00 rdm Exp $ */ /************************************************************************* * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * @@ -30,5 +30,7 @@ #pragma link C++ class TAttImage; #pragma link C++ class TImagePalette; #pragma link C++ class TPaletteEditor; +#pragma link C++ class TText-; +#pragma link C++ class TTF; #endif diff --git a/graf/inc/TLatex.h b/graf/inc/TLatex.h index 6b0232fc23e..443f3390c1c 100644 --- a/graf/inc/TLatex.h +++ b/graf/inc/TLatex.h @@ -1,4 +1,4 @@ -// @(#)root/graf:$Name: $:$Id: TLatex.h,v 1.8 2002/05/03 09:34:20 brun Exp $ +// @(#)root/graf:$Name: $:$Id: TLatex.h,v 1.9 2002/10/31 07:27:34 brun Exp $ // Author: Nicolas Brun 07/08/98 /************************************************************************* @@ -112,9 +112,10 @@ public: TLatex *DrawLatex(Double_t x, Double_t y, const char *text); Double_t GetHeight() const; - virtual void GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const; Double_t GetXsize(); Double_t GetYsize(); + void GetBoundingBox(UInt_t &w, UInt_t &h); + void GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const; virtual void Paint(Option_t *option=""); virtual void PaintLatex(Double_t x, Double_t y, Double_t angle, Double_t size, const char *text); diff --git a/graf/inc/TText.h b/graf/inc/TText.h index 3d157d9e2dd..e81ec068981 100644 --- a/graf/inc/TText.h +++ b/graf/inc/TText.h @@ -1,4 +1,4 @@ -// @(#)root/graf:$Name: $:$Id: TText.h,v 1.3 2000/12/13 15:13:50 brun Exp $ +// @(#)root/graf:$Name: $:$Id: TText.h,v 1.4 2002/10/31 07:27:34 brun Exp $ // Author: Nicolas Brun 12/12/94 /************************************************************************* @@ -34,39 +34,43 @@ class TText : public TNamed, public TAttText { protected: - Double_t fX; //X position of text (left,center,etc..) - Double_t fY; //Y position of text (left,center,etc..) + Double_t fX; // X position of text (left,center,etc..) + Double_t fY; // Y position of text (left,center,etc..) public: - // TText status bits - enum { kTextNDC = BIT(14) }; - - TText(); - TText(Double_t x, Double_t y, const char *text); - TText(const TText &text); - virtual ~TText(); - void Copy(TObject &text) const; - virtual Int_t DistancetoPrimitive(Int_t px, Int_t py); - virtual TText *DrawText(Double_t x, Double_t y, const char *text); - virtual TText *DrawTextNDC(Double_t x, Double_t y, const char *text); - virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py); - - Double_t GetX() const {return fX;} - Double_t GetY() const {return fY;} - - virtual void ls(Option_t *option="") const; - virtual void Paint(Option_t *option=""); - virtual void PaintText(Double_t x, Double_t y, const char *text); - virtual void PaintTextNDC(Double_t u, Double_t v, const char *text); - virtual void Print(Option_t *option="") const; - virtual void SavePrimitive(ofstream &out, Option_t *option); - virtual void SetNDC(Bool_t isNDC=kTRUE); - virtual void SetText(Double_t x, Double_t y, const char *text) {fX=x; fY=y; SetTitle(text);} // *MENU* *ARGS={x=>fX,y=>fY,text=>fTitle} - virtual void SetX(Double_t x) { fX = x;} // *MENU* - virtual void SetY(Double_t y) { fY = y;} // *MENU* - - ClassDef(TText,2) //Text + // TText status bits + enum { kTextNDC = BIT(14) }; + + TText(); + TText(Double_t x, Double_t y, const char *text); + TText(const TText &text); + virtual ~TText(); + void Copy(TObject &text) const; + virtual Int_t DistancetoPrimitive(Int_t px, Int_t py); + virtual TText *DrawText(Double_t x, Double_t y, const char *text); + virtual TText *DrawTextNDC(Double_t x, Double_t y, const char *text); + virtual void ExecuteEvent(Int_t event, Int_t px, Int_t py); + + virtual void GetControlBox(Int_t x, Int_t y, Double_t theta, + Int_t cBoxX[4], Int_t cBoxY[4]); + Double_t GetX() const { return fX; } + virtual void GetBoundingBox(UInt_t &w, UInt_t &h); + virtual void GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const; + Double_t GetY() const { return fY; } + + virtual void ls(Option_t *option="") const; + virtual void Paint(Option_t *option=""); + virtual void PaintControlBox(Int_t x, Int_t y, Double_t theta); + virtual void PaintText(Double_t x, Double_t y, const char *text); + virtual void PaintTextNDC(Double_t u, Double_t v, const char *text); + virtual void Print(Option_t *option="") const; + virtual void SavePrimitive(ofstream &out, Option_t *option); + virtual void SetNDC(Bool_t isNDC=kTRUE); + virtual void SetText(Double_t x, Double_t y, const char *text) {fX=x; fY=y; SetTitle(text);} // *MENU* *ARGS={x=>fX,y=>fY,text=>fTitle} + virtual void SetX(Double_t x) { fX = x; } // *MENU* + virtual void SetY(Double_t y) { fY = y; } // *MENU* + + ClassDef(TText,2) //Text }; #endif - diff --git a/graf/src/TLatex.cxx b/graf/src/TLatex.cxx index 3f26eb372d2..2529fb9ecb7 100644 --- a/graf/src/TLatex.cxx +++ b/graf/src/TLatex.cxx @@ -1,4 +1,4 @@ -// @(#)root/graf:$Name: $:$Id: TLatex.cxx,v 1.32 2002/10/03 17:46:11 brun Exp $ +// @(#)root/graf:$Name: $:$Id: TLatex.cxx,v 1.33 2002/10/31 07:27:35 brun Exp $ // Author: Nicolas Brun 07/08/98 /************************************************************************* @@ -14,6 +14,7 @@ #include "Riostream.h" #include "TROOT.h" #include "TLatex.h" +#include "TTF.h" #include "TVirtualPad.h" #include "TVirtualPS.h" #include "TArc.h" @@ -658,10 +659,10 @@ const char *tab3[] = { "bar","vec","dot","hat","ddot","acute","grave","check","t Double_t prop=1, propU=1; // scale factor for #sum & #int switch (AbovePlace) { case 1 : - prop = .8 ; propU = 1.5 ; // Int + prop = .8 ; propU = 1.75 ; // Int break; case 2: - prop = .8 ; propU = 1.5 ; // Sum + prop = .9 ; propU = 1.75 ; // Sum break; } // propU acts on upper number @@ -753,9 +754,9 @@ const char *tab3[] = { "bar","vec","dot","hat","ddot","acute","grave","check","t Double_t xfpos = 0. ; //GetHeight()*spec.size/5. ; switch (AbovePlace) { case 1 : //int - prop = 1.5 ; break ; + prop = 1.75 ; break ; case 2 : // sum - prop=1.5; break ; + prop = 1.75; break ; } // When increasing prop, the upper indice position is higher if(!fShow) { @@ -803,7 +804,7 @@ const char *tab3[] = { "bar","vec","dot","hat","ddot","acute","grave","check","t } else if (OpUnder>-1) { // _ found - Double_t prop = .8; // scale factor for #sum & #frac + Double_t prop = .9; // scale factor for #sum & #frac Double_t xfpos = 0.;//GetHeight()*spec.size/5. ; Double_t fpos = fFactorPos ; // When increasing prop, the lower indice position is lower @@ -1840,6 +1841,48 @@ Double_t TLatex::GetXsize() return TMath::Abs(gPad->AbsPixeltoX(Int_t(fs.Width())) - gPad->AbsPixeltoX(0)); } +//______________________________________________________________________________ +void TLatex::GetBoundingBox(UInt_t &w, UInt_t &h) +{ +// return text size in pixels + if (!gPad) return; + TString newText = GetTitle(); + if( newText.Length() == 0) return; + fError = 0 ; + if (CheckLatexSyntax(newText)) { + cout<<"\n*ERROR<TLatex>: "<<fError<<endl; + cout<<"==> "<<GetTitle()<<endl; + return; + } + fError = 0 ; + + const Char_t *text = newText.Data() ; + FormSize fs = FirstParse(GetTextAngle(),GetTextSize(),text); + delete[] fTabSize; + w = (UInt_t)fs.Width(); + h = (UInt_t)fs.Height(); +} + +//______________________________________________________________________________ +void TLatex::GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const +{ +// Return text extent for a string text. No TLatex parsing is done. +// It uses the TTF text extent. It is used to get the size of various +// pieces of text in a TLatex string +// in w return total text width +// in h return text height + + Double_t wh = (Double_t)gPad->XtoPixel(gPad->GetX2()); + Double_t hh = (Double_t)gPad->YtoPixel(gPad->GetY1()); + Double_t tsize; + if (wh < hh) tsize = fTextSize*wh; + else tsize = fTextSize*hh; + + TTF::SetTextFont(fTextFont); + TTF::SetTextSize(tsize); + TTF::GetTextExtent(w, h, (char*)text); +} + //______________________________________________________________________________ Double_t TLatex::GetYsize() { @@ -1926,445 +1969,3 @@ void TLatex::SetLimitIndiceSize(Int_t limitFactorSize) // Set limit for text resizing of subscipts and superscripts fLimitFactorSize = limitFactorSize; } -//______________________________________________________________________________ -void TLatex::GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const -{ -// Return text extent for string text -// in w return total text width -// in h return text height - const UChar_t width12[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23,32,39,47,47,74,69,20,30,30,47,63,23,31,23,26,47,47,47,47,47,47,47,47,47,47,31,31,63,63,63,47, - 85,57,57,62,67,57,57,67,67,31,41,62,52,77,62,67,57,67,57,47,52,67,57,76,57,52,52,36,26,40,39,47, - 32,47,47,41,47,41,26,47,47,26,26,41,26,67,47,47,47,47,36,36,26,47,41,62,41,41,36,37,26,37,50, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23,37,47,47,46,47,26,47,28,68,26,47,63,31,69,47,37,51,28,27,31,54,49,31,31,28,29,47,70,70,70,44, - 57,57,57,57,57,57,83,62,57,57,57,57,31,31,31,31,67,62,67,67,67,67,67,63,67,67,67,67,67,52,57,47, - 47,47,47,47,47,47,62,41,41,41,41,41,26,26,26,26,47,47,47,47,47,47,47,51,47,47,47,47,47,41,45,41}; - const UChar_t trail12[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 5, 2, 0, 3, 0, 6,13, 6, 0, 0, 0, 0, 0,15, 1, 0, 0, 0, 2, 1, 4, 4, 1, 1, 0, 0, 0, 0, 0, 0, - 0, 2, 3, 4, 3, 6, 9, 3,14,13,16,11, 1,16,14, 2, 3, 2, 4, 6,12,12,13,13,20,12, 7,11, 0, 7, 4, 4, - 3, 2, 0, 0, 9, 0,36, 7, 0, 2,19, 7, 5, 0, 0, 0,10, 1, 2, 1, 4, 2, 1, 0, 4,10, 4,11, 0, 4, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 4, 2,14, 0, 3, 9, 2,12, 0, 0, 0, 2,12, 3, 1, 4, 4, 5, 0, 0, 3, 0, 4, 9, 0, 0, 0, 0, 0, - 3, 8, 7,13, 9, 8, 7, 4, 6, 6, 6, 6,13,14,14,13, 2,14, 2, 2, 2, 2, 2, 0, 4,12,12,12,12,12, 5,15, - 2, 2, 2, 4, 2, 2, 0, 0, 0, 1, 0, 0, 2, 8, 6, 8, 0, 0, 0, 0, 0, 0, 0, 1, 1, 2, 2, 2, 2,10,11,10}; - const UChar_t height12[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,66,65,67,74,66,66,65,86,86,67,55,22,26,11,68,66,65,65,66,65,65,66,65,66,66,45,56,55,41,55,66, - 89,65,64,66,64,64,64,66,64,64,65,64,64,64,65,66,64,85,64,66,64,65,65,65,64,64,64,84,68,84,65,20, - 67,45,68,45,68,45,87,64,68,63,82,68,68,45,45,45,64,64,44,45,56,45,45,45,45,64,43,87,87,87,32, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,66,78,66,55,64,87,86,61,66,65,45,41,26,66,71,65,54,65,65,65,63,84,38,19,66,65,45,68,68,68,66, - 85,85,84,82,78,77,64,82,85,85,84,78,85,85,84,78,64,83,86,86,85,83,79,52,68,86,86,85,79,85,64,87, - 65,65,64,62,58,64,45,61,65,65,64,58,65,65,64,58,68,62,65,65,64,62,58,50,49,65,65,64,58,84,87,77}; - - const UChar_t width22[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23,31,52,47,47,92,77,26,31,31,47,53,23,31,23,26,47,47,47,47,47,47,47,47,47,47,31,31,53,53,53,47, - 87,67,62,67,67,62,57,72,72,36,47,73,62,88,67,72,57,72,67,52,62,67,67,93,66,67,61,31,26,31,54,47, - 31,47,52,41,52,41,32,47,52,26,31,52,26,77,52,47,52,52,41,36,31,52,47,68,47,47,40,37,20,37,48, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23,31,47,47,47,47,20,47,34,69,28,47,53,31,69,47,37,51,28,28,31,54,50,31,31,28,31,47,70,70,70,47, - 67,67,67,67,67,67,93,67,62,62,62,62,36,36,36,36,67,67,72,72,72,72,72,53,72,67,67,67,67,67,57,52, - 47,47,47,47,47,47,67,41,41,41,41,41,26,26,26,26,47,52,47,47,47,47,47,51,47,52,52,52,52,47,52,47}; - const UChar_t trail22[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 3, 3, 0, 1, 1, 0, 0, 0, 2, 0, 0, 1, 2, 2, 2, 1, 1, 0, 2, 0, 0, 4, - 0, 0, 0, 0, 0, 0,10, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 0, 1, 2, 1, 1, 0, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 2, 0, 0, 1, 0, 2, 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 2, 2, 4, 0, 0, 0, 1, 1, 0, 1, 0, - 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 5, 7, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1}; - const UChar_t height22[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,66,65,64,72,66,66,65,84,84,65,56,32,28,17,66,66,65,65,66,65,65,66,64,66,66,46,60,53,43,53,66, - 84,65,64,66,64,64,64,66,64,64,65,64,64,64,65,67,64,81,64,66,64,65,65,65,64,64,64,82,66,82,65,20, - 65,46,65,46,65,46,65,65,64,65,85,64,64,45,45,46,65,65,45,46,61,45,45,45,44,64,44,85,85,85,34, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,66,81,66,55,64,85,85,64,66,65,44,43,28,66,74,65,57,65,65,65,64,84,41,19,65,65,44,68,67,67,66, - 85,85,87,82,83,80,64,82,85,85,87,83,85,85,87,83,64,83,86,86,88,83,84,54,71,86,86,88,84,85,64,65, - 65,65,67,62,63,68,46,62,65,65,67,63,64,64,66,62,66,61,65,65,67,62,63,51,49,65,65,67,63,84,84,82}; - - const UChar_t width32[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23,35,52,46,47,79,72,26,31,31,47,53,23,31,23,26,47,47,47,47,47,47,47,47,47,47,31,31,53,53,53,47, - 77,62,62,62,67,62,62,67,72,36,47,62,57,83,67,67,57,67,62,52,57,67,60,83,62,57,57,31,26,31,53,47, - 31,47,47,41,47,41,31,47,52,26,26,47,26,73,52,47,47,47,36,36,26,52,41,62,47,41,36,32,20,32,54, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23,36,47,47,46,47,20,47,31,70,25,47,56,31,69,47,37,51,28,28,31,54,47,30,31,28,28,47,69,70,70,47, - 62,62,62,62,62,62,88,62,62,62,62,62,36,36,36,36,67,67,67,67,67,67,67,53,67,67,67,67,67,57,57,47, - 47,47,47,47,47,47,67,41,41,41,41,41,26,26,26,26,47,52,47,47,47,47,47,51,47,52,52,52,52,41,46,41}; - const UChar_t trail32[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 2, 0, 0, 4,12, 7, 2, 3, 0, 1, 0,23, 2, 0, 0, 0, 1, 3, 5, 7, 1, 1, 0, 0, 2, 2, 2, 0, - 6, 3, 3, 7, 4, 7, 9, 4,15,13,11,14, 1,14,15, 2, 8, 2, 2, 7, 9,10,15,12,18,12,11,15, 0,15, 0, 4, - 0, 1, 0, 1, 7, 1,34, 6, 0, 4,17, 3, 6, 0, 0, 0,10, 2, 3, 3, 5, 1, 2, 1, 7,10, 6,15, 0,10, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 5, 2,14, 0, 5, 6, 1,12, 1, 0, 1, 2,16, 4, 2, 6, 5, 8, 4, 6, 5, 0, 3, 9, 0, 0, 0, 0, 0, - 3,10, 9,13,11, 6, 9, 7, 7, 7, 7, 7,13,17,15,14, 1,15, 2, 2, 2, 2, 2, 0, 3,10,10,10,10,12, 3,18, - 1, 2, 1, 3, 1, 1, 2, 1, 1, 5, 4, 5, 0,12, 8, 9, 0, 0, 0, 2, 0, 2, 0, 2, 0, 1, 1, 1, 1,10,11,10}; - const UChar_t height32[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,66,65,65,73,68,66,65,85,85,65,58,31,27,16,66,66,65,65,66,64,65,66,65,66,66,46,60,53,44,53,66, - 85,65,64,66,64,64,64,66,64,64,65,64,64,64,64,66,64,84,64,66,64,65,65,65,64,64,64,82,66,82,65,20, - 65,46,66,46,66,46,85,65,66,66,85,66,66,46,46,46,65,65,45,46,58,46,46,46,46,65,52,84,85,84,34, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,65,80,66,55,64,85,85,62,66,65,44,44,27,66,74,65,58,65,65,65,64,84,38,19,65,65,44,67,67,68,66, - 86,86,86,83,81,80,64,82,86,86,86,81,86,86,86,81,64,83,87,87,87,84,82,52,67,87,87,87,82,86,64,85, - 66,66,66,63,61,69,46,62,66,66,66,61,66,66,66,61,66,63,66,66,66,63,61,51,46,66,66,66,61,85,85,80}; - - const UChar_t width42[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25,26,33,52,52,83,62,18,31,31,36,54,26,31,26,26,52,52,52,52,52,52,52,52,52,52,26,26,54,54,54,52, - 94,62,62,67,67,62,57,72,67,26,47,62,52,77,67,72,62,72,67,62,57,67,62,93,62,61,57,26,26,26,41,52, - 31,52,52,47,52,52,27,52,52,21,21,47,21,79,52,52,52,52,31,47,26,52,47,67,47,45,46,31,23,31,54, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25,28,52,52,52,52,23,52,31,69,34,52,54,31,69,51,37,51,31,31,31,54,50,31,31,31,34,52,78,78,78,57, - 62,62,62,62,62,62,93,67,62,62,62,62,26,26,26,26,67,67,72,72,72,72,72,54,72,67,67,67,67,61,62,57, - 52,52,52,52,52,52,83,47,52,52,52,52,26,26,26,26,52,52,52,52,52,52,52,51,57,52,52,52,52,45,52,45}; - const UChar_t trail42[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 1, 1, 2, 0, 0, 3, 0, 0, 4, - 0, 0, 0, 1, 0, 0, 5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 0, 2, 0, 1, 4, 2, 2, 0, 0, 1, 0, 0, 0, -// 0, 0, 0, 1, 0, 0, 5, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 3, 0, 2, 0, 1, 4, 2, 2, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 5, 0, 0, 0, 0, 0, 0, 2, 1, 0, 0, 0, 0, 1, 0, 1, 0, - 3, 3, 3, 3, 3, 3, 0, 0, 0, 0, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2}; - const UChar_t height42[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,69,69,69,82,71,71,69,87,87,69,57,24,30,10,69,70,69,69,70,68,69,70,68,70,70,51,65,57,49,57,70, - 90,69,69,71,69,69,69,71,69,69,70,69,69,69,69,71,69,76,69,71,69,70,69,69,69,69,69,87,69,87,70,18, - 69,53,70,53,70,53,70,71,69,69,88,69,69,52,52,53,70,70,52,53,69,52,51,51,51,70,51,89,89,89,42, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,69,88,71,54,69,89,89,69,71,70,47,48,30,71,81,70,58,70,70,68,69,87,40,20,70,70,47,72,71,72,70, - 86,86,86,85,81,83,69,88,86,86,86,81,86,86,86,81,69,85,87,87,87,86,82,57,75,87,87,87,82,86,69,71, - 70,70,70,69,65,74,53,70,70,70,70,65,69,69,69,64,70,68,70,70,70,69,65,53,59,70,70,70,65,88,87,83}; - - const UChar_t width52[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25,26,33,52,52,83,62,18,31,31,36,54,26,31,26,26,52,52,52,52,52,52,52,52,52,52,26,26,54,54,54,52, - 94,62,62,67,67,62,57,72,67,26,47,62,52,77,67,72,62,72,67,62,57,67,62,89,62,62,57,26,26,26,44,52, - 31,52,52,47,52,52,26,52,52,21,21,47,21,76,52,52,52,52,31,47,26,52,47,67,47,47,44,31,24,31,54, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25,31,52,52,50,52,24,52,31,70,34,52,54,31,70,51,37,51,31,33,31,51,50,31,31,30,34,52,78,78,78,57, - 62,62,62,62,62,62,93,67,62,62,62,62,26,26,26,26,67,67,72,72,72,72,72,54,72,67,67,67,67,62,62,57, - 52,52,52,52,52,52,83,47,52,52,52,52,26,26,26,26,52,52,52,52,52,52,52,51,57,52,52,52,52,47,52,47}; - const UChar_t trail52[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 2,10, 4, 3, 0, 0, 9, 8, 1, 6, 1, 0, 1, 0,20, 3, 0, 2, 2, 1, 4, 3, 6, 3, 1, 0, 0, 0, 0, 0, 1, - 0, 0, 0, 3, 1, 6, 6, 1, 5, 4, 5, 9, 0, 6, 6, 1, 5, 1, 3, 2,11, 5,11,14,16,12, 5,12, 4,14, 5, 5, - 0, 0, 0, 3, 6, 0,14, 4, 0, 7,18, 7, 7, 2, 0, 0, 1, 2,11, 2, 6, 2, 6, 8, 3, 7, 3,13, 1, 7, 1, 0, -// 0, 0, 0, 3, 6, 0,14, 4, 0, 7,18, 7, 7, 2, 0, 0, 1, 2,11, 2, 6, 2, 6, 8, 3, 7, 3,13, 0, 7, 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, 5, 3,12, 0, 2, 7, 7, 5, 0, 0, 1, 7,12, 2, 0, 8, 7, 7, 6, 8, 4, 0, 6, 6, 0, 4, 2, 5, 0, - 0, 0, 0, 0, 0, 0, 9, 3, 6, 6, 6, 6, 7,12,14,16, 1, 6, 1, 1, 1, 1, 1, 0, 2, 5, 5, 5, 5,12, 3, 0, - 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 0, 5, 9,10,13, 1, 0, 0, 0, 0, 0, 0, 0, 1, 2, 2, 2, 2, 7, 0, 7}; - const UChar_t height52[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,69,69,69,79,72,71,69,87,87,69,57,24,30,10,69,70,69,69,70,68,69,70,68,70,70,51,65,57,49,57,70, - 89,69,69,71,69,69,69,71,69,69,70,69,69,69,69,71,69,79,69,71,69,70,69,69,69,69,69,87,69,87,70,18, - 69,53,70,53,70,53,70,71,69,69,88,69,69,52,52,53,70,70,52,53,70,52,51,51,51,70,51,89,87,89,42, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,69,88,71,55,69,87,89,69,71,70,46,49,30,71,81,70,58,70,70,69,69,87,39,22,70,70,46,73,73,73,70, - 85,85,86,84,81,81,69,90,85,85,86,81,85,85,86,81,69,84,86,86,87,85,82,55,81,86,86,87,82,85,69,71, - 69,69,70,68,65,72,54,72,69,69,70,65,68,68,69,64,71,67,69,69,70,68,65,50,59,69,69,70,65,87,87,83}; - - const UChar_t width62[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25,29,44,52,52,81,67,22,31,31,36,54,26,31,26,26,52,52,52,52,52,52,52,52,52,52,31,31,54,54,54,57, - 91,63,67,67,67,62,57,72,67,26,52,67,57,79,67,72,62,72,67,62,57,67,62,87,62,61,57,31,26,31,54,52, - 31,52,57,52,57,52,31,57,57,26,25,52,26,83,57,57,57,57,36,52,31,57,50,74,52,51,47,36,26,36,54, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25,31,52,52,52,52,26,52,31,69,34,52,54,31,69,51,37,51,31,31,31,54,52,31,30,31,34,52,78,78,78,57, - 63,63,63,63,63,63,93,67,62,62,62,62,26,26,26,26,67,67,72,72,72,72,72,54,72,67,67,67,67,61,62,57, - 52,52,52,52,52,52,83,52,52,52,52,52,26,26,26,26,57,57,57,57,57,57,57,51,57,57,57,57,57,51,57,51}; - const UChar_t trail62[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 2, 2, 4, 0, 2, 3, 0, 0, 4, - 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 2, 0, 1, 1, 2, 1, 0, 0, 2, 0, 0, 0, -// 0, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 2, 0, 1, 1, 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, 2, 3, 0, 0, 0, 1, 3, 3, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 0, 1, 0, 1, 0, - 2, 2, 2, 2, 2, 2, 1, 0, 0, 0, 0, 0, 0, 0, 5, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 5, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1}; - const UChar_t height62[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,69,69,69,83,73,71,69,87,87,69,57,30,31,15,69,70,69,69,70,68,69,70,68,70,70,51,66,61,51,61,70, - 91,69,69,70,69,69,69,71,69,69,70,69,69,69,69,71,69,76,69,71,69,70,69,69,69,69,69,87,69,87,70,18, - 69,53,70,53,70,53,70,71,69,69,88,69,69,52,52,53,70,70,52,53,69,52,51,51,51,70,51,89,89,89,43, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,69,88,71,59,69,89,90,69,71,70,47,51,31,71,80,70,62,70,70,69,69,87,41,19,70,70,47,70,71,71,70, - 89,89,89,87,86,82,69,87,89,89,89,86,89,89,89,86,69,87,90,90,90,88,87,56,77,90,90,90,87,89,69,71, - 72,72,72,70,69,76,53,69,72,72,72,69,71,71,71,68,70,69,72,72,72,70,69,55,57,72,72,72,69,90,87,87}; - - const UChar_t width72[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25,31,44,52,52,87,67,21,31,30,36,54,26,31,26,26,52,52,52,52,52,52,52,52,52,52,31,31,54,54,54,57, - 91,67,67,67,67,62,57,72,67,26,52,67,57,77,67,72,62,72,67,62,57,67,62,88,62,62,57,31,26,32,54,52, - 31,52,57,52,57,52,31,57,57,26,26,52,26,83,57,57,57,57,36,52,31,57,52,72,52,52,47,36,26,36,54, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 25,31,53,52,52,52,26,52,31,69,34,52,54,31,69,51,37,52,31,31,31,54,51,31,31,31,34,52,78,78,78,57, - 67,67,67,67,67,67,93,67,62,62,62,62,26,26,26,26,67,67,72,72,72,72,72,54,72,67,67,67,67,62,62,57, - 52,52,52,52,52,52,83,52,52,52,52,52,26,26,26,26,57,57,57,57,57,57,57,51,57,57,57,57,57,52,57,52}; - const UChar_t trail72[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 3, 6, 4, 5, 0, 1,11,11, 7, 8, 2, 0, 2, 0,19, 4, 0, 3, 2, 3, 4, 2, 7, 3, 3, 2, 2, 2, 2, 2, 3, - 5, 0, 1, 4, 2, 7, 9, 3, 6, 7, 6, 9, 0, 7, 6, 2, 6, 2, 4, 2,11, 8,14,14,16,14, 7,13, 2,12, 2, 3, - 2, 1, 0, 2, 9, 2,14, 5, 1, 7,20, 7, 7, 2, 0, 0, 1, 4,10, 2, 7, 3, 7,10, 9, 9, 3,11, 0, 7, 2, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 7, 4,13, 0, 3,13, 6, 7, 4, 3, 2, 6,11, 5, 2, 8, 8, 9, 8, 6,11, 0, 5, 6, 1, 4, 2, 4, 0, - 0, 0, 0, 0, 0, 0,11, 4, 7, 7, 7, 7, 8,14,15,21, 2, 6, 2, 2, 2, 2, 2, 0, 3, 8, 8, 8, 8,14, 2, 0, - 1, 1, 1, 1, 4, 1, 2, 2, 2, 2, 2, 4, 5,11,12,17, 2, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 9, 3, 9}; - const UChar_t height72[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,69,69,69,83,71,71,69,87,87,70,58,29,33,15,69,70,69,69,70,68,69,70,68,70,70,51,65,61,51,61,70, - 90,69,69,71,69,69,69,71,69,69,70,69,69,69,69,71,69,78,69,71,69,70,69,69,69,69,69,87,69,87,70,19, - 70,53,70,53,70,53,70,71,69,69,88,69,69,52,52,53,71,71,52,53,68,52,51,51,51,70,51,89,89,89,44, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,69,87,71,59,69,89,90,70,71,70,46,51,33,71,80,70,64,70,70,70,69,88,42,20,70,70,46,71,72,71,70, - 87,87,87,85,86,82,69,88,87,87,87,86,87,87,87,86,69,85,88,88,88,86,87,58,80,88,88,88,87,87,69,71, - 71,71,71,69,70,73,53,70,71,71,71,70,70,70,70,69,70,68,71,71,71,69,70,60,61,71,71,71,70,89,87,88}; - - const UChar_t width82[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56}; - const UChar_t trail82[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 0, - 1, 1, 1, 1, 1, 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}; - const UChar_t height82[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,60,59,69,73,60,52,59,71,71,59,52,29,31,14,73,61,61,60,61,59,60,61,59,61,61,43,50,53,38,53,58, - 66,55,55,57,55,55,55,57,55,55,56,55,55,55,55,57,55,67,55,57,55,56,55,55,55,55,55,71,73,71,61,25, - 62,44,60,44,60,44,59,61,59,62,80,59,59,43,43,44,61,61,43,44,57,43,42,42,42,60,42,71,71,71,35, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,60,62,56,49,55,70,65,59,57,62,45,30,31,58,67,70,58,59,59,62,60,65,37,18,59,62,45,59,59,59,61, - 74,74,73,70,67,76,55,72,74,74,73,67,74,74,73,67,55,70,75,75,74,71,68,45,63,75,75,74,68,74,55,60, - 63,63,62,59,56,65,44,59,63,63,62,56,62,62,61,55,60,58,63,63,62,59,56,49,47,63,63,62,56,80,77,73}; - - const UChar_t width92[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56}; - const UChar_t trail92[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 1, 3, 0, 0, 2, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 5, 3, 0, 0, 0, 0, 5, 4, 4, 0, - 0, 3, 1, 7, 3, 4,11, 8, 9, 3,11,13, 1,12,12, 6, 7, 4, 3, 3, 8,12,13,11, 8, 9, 2, 0, 0, 0, 0, 4, - 0, 0, 1, 2, 6, 0, 8, 6, 0, 0, 0, 1, 0, 0, 0, 0, 6, 8, 4, 0, 0, 1, 8,10, 2, 5, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 9, 0, 6, 0, 7, 0, 2, 2, 0, 7,16, 0, 2, 0, 0, 0, 1, 7, 0, 0, 0, 0, 4, 5, 8, 5, 0, - 1, 1, 1, 1, 1, 3,11, 7, 4, 4, 4, 4, 3, 3, 3, 3, 1,12, 6, 6, 6, 6, 6, 0,11,12,12,12,12, 9, 3, 0, - 0, 0, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 2, 5, 1, 1, 1, 1, 5, 3, 5}; - const UChar_t height92[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,61,59,69,73,61,52,59,71,71,59,51,29,30,14,73,61,61,60,61,59,60,61,59,61,61,43,52,52,37,52,57, - 67,55,55,57,55,55,55,57,55,55,56,55,55,55,55,57,55,67,55,57,55,56,55,55,55,55,55,71,73,71,60,26, - 62,44,60,44,60,44,59,61,59,62,80,59,59,43,43,44,61,61,43,44,57,43,42,42,42,60,42,71,71,71,35, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,60,63,56,48,55,70,66,59,57,59,42,30,30,58,69,68,55,59,59,62,60,65,37,19,59,59,42,59,60,59,61, - 75,75,74,70,68,80,55,71,75,75,74,68,75,75,74,68,55,70,76,76,75,71,69,44,61,76,76,75,69,75,55,60, - 64,64,63,59,57,69,44,58,64,64,63,57,63,63,62,56,60,58,64,64,63,59,57,50,48,64,64,63,57,81,77,74}; - - const UChar_t width102[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56}; - const UChar_t trail102[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, - 0, 7, 0, 0, 0, 0, 1, 3, 0, 0, 3, 3, 0, 7, 2, 0, 0, 0, 4, 0, 0, 1, 7, 7, 2, 0, 0, 0, 0, 0, 0,10, - 0, 0, 1, 0, 3, 0, 0, 1, 0, 0, 0, 0, 0, 3, 0, 0, 1, 3, 0, 0, 1, 0, 1, 2, 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, 2, 0, 0, 0, 0, 2,10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 7, 1, 0, - 7, 7, 7, 7, 7, 7, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 7, 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}; - const UChar_t height102[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,60,55,71,77,60,55,55,72,72,59,52,29,33,14,79,61,60,60,61,59,60,61,59,61,61,42,51,55,41,55,57, - 66,55,55,57,55,55,55,57,55,55,56,55,55,55,55,57,55,70,55,57,55,56,55,55,55,55,55,71,78,71,64,28, - 64,44,60,44,60,44,59,61,59,59,77,59,59,43,43,44,61,61,43,44,58,43,42,42,42,60,42,71,71,71,38, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,60,70,56,49,55,71,67,60,56,62,39,33,33,56,73,70,61,62,62,64,60,67,42,21,62,62,39,62,62,61,60, - 78,78,78,76,72,80,55,72,78,78,78,72,78,78,78,72,55,76,79,79,79,77,73,47,66,79,79,79,73,78,55,60, - 65,65,65,63,59,67,44,59,65,65,65,59,64,64,64,58,60,62,65,65,65,63,59,53,53,65,65,65,59,82,77,76}; - - const UChar_t width112[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 55,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56, - 56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56,56}; - const UChar_t trail112[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 4, 4, 3, 2, 0, 3, 0, 2, 5, 0, 0, 0, 7, 2, 0, 3, 3, 0, 4, 8, 6, 4, 4, 0, 0, 8, 8,10, 2, - 4, 7, 5, 9, 8, 7,13, 8,10, 3,12,11, 4,16,11, 7, 4, 7, 6, 5,10,11,12,14, 9, 9, 5, 2, 0, 0, 2,10, - 0, 1, 5, 4, 9, 3,11, 9, 3, 0, 0, 4, 0, 9, 3, 3, 9,11, 7, 1, 3, 3, 9,11, 6,11, 3, 0, 0, 0, 3, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 2, 0, 4,15, 0, 6, 0, 7, 0, 6, 6, 0, 8,19, 0, 5, 0, 0, 1, 3, 9, 0, 0, 0, 0, 4, 7, 9, 8, 0, - 7, 7, 7, 7, 7, 7,16, 9, 7, 7, 7, 7, 3, 4, 3, 3, 8,11, 7, 7, 7, 7, 7, 0,14,11,11,11,11, 9, 5, 0, - 1, 1, 1, 2, 1, 1, 8, 4, 3, 3, 3, 3, 0, 0, 0, 0, 6, 3, 3, 3, 3, 3, 3, 4, 8, 3, 3, 3, 3,11, 9,11}; - const UChar_t height112[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,63,56,75,75,60,55,56,71,71,59,53,29,33,14,79,61,61,60,61,59,60,61,59,61,61,43,52,54,42,54,60, - 67,55,55,57,55,55,55,57,55,55,56,55,55,55,55,57,55,69,55,57,55,56,55,55,55,55,55,71,78,71,64,28, - 64,44,60,44,60,44,59,61,59,59,77,59,59,43,43,44,61,61,43,44,58,43,42,42,42,60,42,71,74,71,38, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,61,68,56,49,55,74,67,59,58,62,41,32,33,58,72,70,65,60,60,60,60,67,39,21,60,62,42,62,64,62,60, - 78,78,77,75,72,81,55,72,78,78,77,72,78,78,77,72,55,75,79,79,78,76,73,48,66,79,79,78,73,78,55,60, - 65,65,64,62,59,68,44,59,65,65,64,59,64,64,63,58,60,61,65,65,64,62,59,53,52,65,65,64,59,82,77,76}; - - const UChar_t width122[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0,23, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23,30,66,47,51,78,73,43,31,31,47,51,24,51,23,26,47,47,47,47,47,47,47,47,47,47,25,24,51,51,51,42, - 52,67,63,67,57,57,74,56,68,30,57,68,65,83,67,67,72,68,52,56,58,65,41,73,62,75,57,32,80,32,62,47, - 45,58,54,51,45,41,47,38,56,30,56,49,52,52,49,51,50,48,50,55,40,54,67,61,45,63,48,46,18,46,50, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0,57,23,51,15,66,46,71,71,70,71,97,92,56,92,56,37,51,38,51,51,66,45,42,51,52,51,50,94,56,93,61, - 76,64,74,93,71,71,77,71,71,66,65,66,66,67,65,65,71,66,73,73,86,76,51,23,66,56,56,97,92,56,92,56, - 46,34,73,73,70,66,36,36,36,36,36,36,46,46,46,47, 0,34,24,64,64,64,36,36,36,36,36,36,46,46,46, 0}; - const UChar_t trail122[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 2, 0, 2, 1, 0, 0, 0, 1, 1, 0, 4, 1, 1, 2, 0, 1, 0, 0, 0, 0, 3, 0, 0, 0, 1, 0, 0, 0, 0, 0, 2, - 46, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, -// 46, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 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,34, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0,12, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 6, 0, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 5, 0, 0, 2, 0, 2, 0, 0, 0, 0, 0, 0, 0}; - const UChar_t height122[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, - 2,66,65,65,64,66,66,46,86,86,52,50,27,28,12,68,66,65,65,66,65,65,66,65,66,66,46,61,49,37,49,66, - 47,65,64,64,65,64,64,64,64,64,68,64,65,64,65,66,64,66,64,64,64,64,65,65,64,65,64,84,48,84,65,20, - 87,46,86,65,68,46,87,65,64,46,65,45,68,64,46,46,45,68,64,45,45,46,45,46,87,65,87,86,87,86,32, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0,65,65,56,66,45,86,56,56,53,55,50,50,87,50,87,65,59,65,57,45,45,68,45,45,50,40,42,12,107,26,61, - 66,66,67,71,66,66,70,48,48,44,57,58,44,57,44,59,65,66,66,66,65,80,91,31,28,44,44,51,51,87,51,87, - 67,84,66,66,65,80,96,96,96,96,96,96,96,96,96,96, 0,84,96,96,101,96,96,96,96,96,96,96,96,96,96, 0}; - - const UChar_t width132[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23,30,38,47,47,77,72,17,31,31,47,52,23,31,23,26,47,47,47,47,47,47,47,47,47,47,26,26,52,52,52,41, - 85,67,62,62,67,57,52,67,67,31,37,67,56,83,67,67,52,67,62,52,57,67,67,88,67,67,56,32,25,32,44,47, - 30,41,46,41,47,41,31,46,47,26,27,46,26,72,47,46,46,46,31,36,26,47,46,66,47,45,41,45,17,45,50, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 23,30,46,47,47,47,18,47,33,71,25,44,52,31,70,47,36,51,28,27,30,54,42,31,28,28,29,44,69,70,70,42, - 67,67,67,67,67,67,82,62,57,57,57,57,31,31,31,31,67,67,67,67,67,67,67,52,67,67,67,67,67,67,52,46, - 41,41,41,41,41,41,62,41,41,41,41,41,26,26,26,26,47,47,46,46,46,46,46,51,47,47,47,47,47,45,46,45}; - const UChar_t trail132[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, - 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 1, 2, 0, 1, 3, 0, 0, 0, 4, 0, 0, 1, 1, 2, 1, 2, 0, 0, 3, 0, 2, 4, - 0, 2, 0, 0, 0, 0,11, 1, 1, 0, 1, 2, 0, 1, 1, 0, 0, 1, 2, 0, 2, 1, 2, 3, 1, 4, 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, 5, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 1, 0, 0, 0, 2, 2, 0, 0, 1, 0, 0, 0, 0, 0, - 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 3, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 0, 0, - 2, 2, 2, 2, 2, 2, 0, 0, 0, 0, 0, 0, 0, 1, 2, 4, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 4, 0, 4}; - const UChar_t height132[256] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,66,65,67,76,66,66,65,85,85,67,57,26,27,12,68,66,65,65,66,65,65,66,65,66,66,46,60,55,44,55,66, - 89,65,64,66,64,64,64,66,64,64,65,64,64,64,65,66,64,83,64,66,64,65,65,65,64,64,64,83,68,83,65,20, - 64,46,68,46,68,46,67,65,67,67,87,67,67,45,45,46,65,65,45,46,59,45,45,45,44,64,44,85,87,85,33, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 2,66,78,66,54,64,87,83,63,66,65,45,41,27,66,72,65,57,65,65,64,64,84,38,20,65,65,45,66,67,66,66, - 85,85,85,82,80,80,64,83,85,85,85,80,85,85,85,80,64,83,86,86,86,83,81,52,66,86,86,86,81,85,64,67, - 65,65,65,62,60,68,46,63,65,65,65,60,64,64,64,59,68,61,65,65,65,62,60,51,50,65,65,65,60,84,87,79}; - - - Double_t wh = (Double_t)gPad->XtoPixel(gPad->GetX2()); - Double_t hh = (Double_t)gPad->YtoPixel(gPad->GetY1()); - Double_t tsize; - if (wh < hh) tsize = fTextSize*wh; - else tsize = fTextSize*hh; - - const UChar_t *width ,*trail, *height; - - switch (fTextFont) { - case 12 : - width = width12 ; trail = trail12 ; height = height12 ; - break ; - case 22 : - width = width22 ; trail = trail22 ; height = height22 ; - break ; - case 32 : - width = width32 ; trail = trail32 ; height = height32 ; - break ; - case 42 : - width = width42 ; trail = trail42 ; height = height42 ; - break ; - case 52 : - width = width52 ; trail = trail52 ; height = height52 ; - break ; - case 62 : - width = width62 ; trail = trail62 ; height = height62 ; - break ; - case 72 : - width = width72 ; trail = trail72 ; height = height72 ; - break ; - case 82 : - width = width82 ; trail = trail82 ; height = height82 ; - break ; - case 92 : - width = width92 ; trail = trail92 ; height = height92 ; - break ; - case 102 : - width = width102 ; trail = trail102 ; height = height102 ; - break ; - case 112 : - width = width112 ; trail = trail112 ; height = height112 ; - break ; - case 122 : - width = width122 ; trail = trail122 ; height = height122 ; - break ; - case 132 : - width = width132 ; trail = trail132 ; height = height132 ; - break ; - default: - width = width62 ; trail = trail62 ; height = height62 ; - break ; - } - - w = h = 0; - UChar_t ut = 0; - const char *t = text; - while(*t) { - ut = (UChar_t)*t; - w += width[ut]; - if (height[ut] > h) h = height[ut]; - t++; - } - if (ut) w += TMath::Max((UInt_t)trail[ut],(UInt_t)5); - w = (UInt_t)((w-0)*tsize/100); - h = (UInt_t)((h+10)*tsize/100); -} - diff --git a/graf/src/TText.cxx b/graf/src/TText.cxx index ff723c50680..532d3aedd84 100644 --- a/graf/src/TText.cxx +++ b/graf/src/TText.cxx @@ -1,4 +1,4 @@ -// @(#)root/graf:$Name: $:$Id: TText.cxx,v 1.13 2002/05/18 08:21:59 brun Exp $ +// @(#)root/graf:$Name: $:$Id: TText.cxx,v 1.14 2002/10/31 07:27:35 brun Exp $ // Author: Nicolas Brun 12/12/94 /************************************************************************* @@ -13,9 +13,10 @@ #include "TROOT.h" #include "TVirtualPad.h" #include "TText.h" +#include "TTF.h" #include "TVirtualX.h" #include "TMath.h" - +#include "TPoint.h" ClassImp(TText) @@ -72,105 +73,34 @@ void TText::Copy(TObject &obj) const //______________________________________________________________________________ Int_t TText::DistancetoPrimitive(Int_t px, Int_t py) { -//*-*-*-*-*-*-*-*-*-*-*Compute distance from point px,py to a string*-*-*-*-* -//*-* ============================================= -// Compute the closest distance of approach from point px,py to this text. -// The rectangle surrounding this string is evaluated. -// if point is in rectangle, the distance is set to zero. -// - Int_t Ax,Ay,Bx,By,Cx,Cy,Dx,Dy,pxl,pxt,pyl,pyt; + // Compute distance from point px,py to a string. + // The rectangle surrounding this string is evaluated. + // If the point (px,py) is in the rectangle, the distance is set to zero. + Int_t ptx, pty; - Ax = Ay = pxl = pxt = pyl = pyt = 0; + + TAttText::Modify(); // change text attributes only if necessary + if (TestBit(kTextNDC)) { - ptx = gPad->UtoPixel(fX); - pty = gPad->VtoPixel(fY); + ptx = gPad->UtoPixel(fX); + pty = gPad->VtoPixel(fY); } else { - ptx = gPad->XtoAbsPixel(fX); - pty = gPad->YtoAbsPixel(fY); - } - const char *text = GetTitle(); - Int_t len = strlen(text); - Double_t fh = (fTextSize*gPad->GetAbsHNDC())*Double_t(gPad->GetWh()); - if (fTextFont%10 > 2) fh = fTextSize; - Int_t h = Int_t(fh/2); - Int_t w = h*len; - Int_t err = 1; - Int_t X1c,X2c,X3c,X4c; - Short_t halign = fTextAlign/10; - Short_t valign = fTextAlign - 10*halign; - if (fTextAngle < err || TMath::Abs(fTextAngle-180) < err || fTextAngle>360-err) { - Int_t signe = 1; - if (TMath::Abs(fTextAngle-180) < err) signe = -1; - switch (halign) { //*-* compute bounding box horizontal alignment - case 1 : pxl = ptx; pxt = ptx + signe*w; break; //left - case 2 : pxl = ptx - signe*w/2; pxt = ptx + signe*w/2; break; //center - case 3 : pxl = ptx - signe*w; pxt = ptx; break; //right - }; - switch (valign) { //*-* compute bounding box vertical alignment - case 1 : pyl = pty - signe*3/2*h; pyt = pty; break; //bottom - case 2 : pyl = pty - signe*h/2; pyt = pty + signe*h/2; break; //center - case 3 : pyl = pty + signe*h/2; pyt = pty + signe*3*h/2; break; //top - }; - if (fTextAngle <err || fTextAngle>360-err) if ((px >= pxl && px <= pxt) && (py >= pyl && py <= pyt)) return 0; - if (TMath::Abs(fTextAngle-180)<2) if ((px <= pxl && px >= pxt) && (py <= pyl && py >= pyt)) return 0; - return 9999; + ptx = gPad->XtoAbsPixel(fX); + pty = gPad->YtoAbsPixel(fY); } - if (TMath::Abs(fTextAngle-90) < err || TMath::Abs(fTextAngle-270)<err) { - Int_t signe = 1; - if (TMath::Abs(fTextAngle-270)<err) signe = -1; - switch (halign) { //*-* compute bounding box horizontal alignment - case 1 : pyt = pty; pyl = pty - signe*w; break; //left - case 2 : pyl = pty - signe*w/2; pyt = pty + signe*w/2; break; //center - case 3 : pyt = pty + signe*w; pyl = pty; break; //right - }; - switch (valign) { //*-* compute bounding box vertical alignment - case 1 : pxl = ptx - signe*3/2*h; pxt = ptx; break; //bottom - case 2 : pxl = ptx - signe*h/2; pxt = ptx + signe*h/2; break; //center - case 3 : pxl = ptx + signe*h/2; pxt = ptx + signe*3*h/2; break; //top - }; - if (TMath::Abs(fTextAngle-90)<err) if ((px >= pxl && px <= pxt) && (py >= pyl && py <= pyt)) return 0; - if (TMath::Abs(fTextAngle-270)<err) if ((px <= pxl && px >= pxt) && (py <= pyl && py >= pyt)) return 0; - return 9999; - } - Double_t co = TMath::Cos(fTextAngle*0.0175); - Double_t si = TMath::Sin(fTextAngle*0.0175); - if (halign == 1) { - switch (valign) { - case 1 : Ax = ptx; Ay = pty; break; - case 2 : Ax = ptx + Int_t((si*h/2+0.5)); Ay = pty + Int_t((co*h/2+0.5)); break; - case 3 : Ax = ptx + Int_t((si*h*3/2+0.5)); Ay = pty + Int_t((co*h*3/2+0.5)); break; - } - } - if (halign == 2) { - switch (valign) { - case 1 : Ax = ptx - Int_t((co*w/2+0.5)); Ay = pty + Int_t((si*w/2+0.5)); break; - case 2 : Ax = ptx - Int_t((co*w/2+si*h/2+0.5)); Ay = pty + Int_t((si*w/2+co*h/2+0.5)); break; - case 3 : Ax = ptx - Int_t((co*w/2+si*h*3/2+0.5)); Ay = pty + Int_t((si*w/2+co*h*3/2+0.5)); break; - } - } - if (halign == 3) { - switch (valign) { - case 1 : Ax = ptx - Int_t((co*w+0.5)); Ay = pty + Int_t((si*w+0.5)); break; - case 2 : Ax = ptx - Int_t((co*w+si*h/2+0.5)); Ay = pty + Int_t((si*w+co*h/2+0.5)); break; - case 3 : Ax = ptx - Int_t((co*w+si*h*3/2+0.5)); Ay = pty + Int_t((si*w+co*h*3/2+0.5)); break; - } + + // Get the text control box + Int_t CBoxX[5], CBoxY[5]; + GetControlBox(ptx, pty, -fTextAngle, CBoxX, CBoxY); + CBoxY[4] = CBoxY[0]; + CBoxX[4] = CBoxX[0]; + + // Check if the point (px,py) is inside the text control box + if(TMath::IsInside(px, py, 5, CBoxX, CBoxY)){ + return 0; + } else { + return 9999; } - Bx = Ax - Int_t((si*h+0.5)); By = Ay - Int_t((co*h+0.5)); - Cx = Bx + Int_t((co*w+0.5)); Cy = By - Int_t((si*w+0.5)); - Dx = Ax + Int_t((co*w+0.5)); Dy = Ay - Int_t((si*w+0.5)); - if (Cy==By) X1c = px; - else X1c = (py-Cy)*(Cx-Bx)/(Cy-By)+Cx; - if (Dy==Cy) X2c = px; - else X2c = (py-Cy)*(Dx-Cx)/(Dy-Cy)+Cx; - if (Dy==Ay) X3c = px; - else X3c = (py-Dy)*(Dx-Ax)/(Dy-Ay)+Dx; - if (Ay==By) X4c = px; - else X4c = (py-Ay)*(Ax-Bx)/(Ay-By)+Ax; - if (fTextAngle<90) if (px >= X1c && px <= X2c && px >= X4c && px <= X3c) return 0; - if (fTextAngle<180) if (px >= X1c && px >= X2c && px <= X4c && px <= X3c) return 0; - if (fTextAngle<270) if (px <= X1c && px >= X2c && px <= X4c && px >= X3c) return 0; - if (fTextAngle<360) if (px <= X1c && px <= X2c && px >= X4c && px >= X3c) return 0; - return 9999; } //______________________________________________________________________________ @@ -208,94 +138,80 @@ void TText::ExecuteEvent(Int_t event, Int_t px, Int_t py) static Int_t px1, py1, pxold, pyold, Size, hauteur, largeur; static Bool_t resize,turn; Int_t dx, dy; - Int_t kMaxDiff = 8; const char *text = GetTitle(); - Int_t len = strlen(text); + Int_t len = strlen(text); Double_t sizetowin = gPad->GetAbsHNDC()*Double_t(gPad->GetWh()); - Double_t fh = (fTextSize*sizetowin); - Int_t h = Int_t(fh/2); - Int_t w = h*len; + Double_t fh = (fTextSize*sizetowin); + Int_t h = Int_t(fh/2); + Int_t w = h*len; Short_t halign = fTextAlign/10; Short_t valign = fTextAlign - 10*halign; - Double_t co,si,dtheta,norm; + Double_t co, si, dtheta, norm; static Bool_t droite; static Double_t theta; - Int_t Ax,Ay,Hx,Hy,Bx,By,Cx,Cy; + Int_t Ax, Ay, Bx, By, Cx, Cy; Ax = Ay = 0; - Double_t lambda, x2,y2,xy; + Double_t lambda, x2,y2; Double_t dpx,dpy,xp1,yp1; + Int_t CBoxX[4], CBoxY[4], Part; if (!gPad->IsEditable()) return; - switch (event) { case kButton1Down: - gVirtualX->SetTextColor(-1); // invalidate current text color (use xor mode) - TAttText::Modify(); //*-*Change text attributes only if necessary - // No break !!! case kMouseMotion: if (TestBit(kTextNDC)) { - px1 = gPad->UtoPixel(fX); - py1 = gPad->VtoPixel(fY); + px1 = gPad->UtoPixel(fX); + py1 = gPad->VtoPixel(fY); } else { - px1 = gPad->XtoAbsPixel(fX); - py1 = gPad->YtoAbsPixel(fY); - } - theta = fTextAngle; - Size = 0; - pxold = px; pyold = py; - co = TMath::Cos(fTextAngle*0.0175); - si = TMath::Sin(fTextAngle*0.0175); - resize = turn = kFALSE; - if (halign == 1) { - switch (valign) { - case 1 : Ax = px1; Ay = py1; break; - case 2 : Ax = px1+Int_t(si*h/2); Ay = py1+Int_t(co*h/2); break; - case 3 : Ax = px1+Int_t(si*h*3/2); Ay = py1+Int_t(co*h*3/2); break; - } - } - if (halign == 2) { - switch (valign) { - case 1 : Ax = px1-Int_t(co*w/2); Ay = py1+Int_t(si*w/2); break; - case 2 : Ax = px1-Int_t(co*w/2+si*h/2); Ay = py1+Int_t(si*w/2+co*h/2); break; - case 3 : Ax = px1-Int_t(co*w/2+si*h*3/2); Ay = py1+Int_t(si*w/2+co*h*3/2); break; - } + px1 = gPad->XtoAbsPixel(fX); + py1 = gPad->YtoAbsPixel(fY); } - if (halign == 3) { - switch (valign) { - case 1 : Ax = px1-Int_t(co*w); Ay = py1+Int_t(si*w); break; - case 2 : Ax = px1-Int_t(co*w+si*h/2); Ay = py1+Int_t(si*w+co*h/2); break; - case 3 : Ax = px1-Int_t(co*w+si*h*3/2); Ay = py1+Int_t(si*w+co*h*3/2); break; - } - } - if (halign != 3) {Hx = Ax+Int_t(co*w-si*h/2); Hy = Ay-Int_t(si*w-co*h/2); droite = kFALSE;} - else {Hx = Ax-Int_t(si*h/2); Hy = Ay-Int_t(co*h/2); droite = kTRUE;} - if ((TMath::Abs(px-Hx)<kMaxDiff*2) && (TMath::Abs(py-Hy)<kMaxDiff*2)) {gPad->SetCursor(kRotate); turn = kTRUE; break;} - Bx = Ax-Int_t(si*h); By = Ay-Int_t(co*h); - if (valign == 3) {Bx = Ax; By = Ay;} - Cx = Bx+Int_t(co*w); Cy = By-Int_t(si*w); - lambda = Double_t(((px-Bx)*(Cx-Bx)+(py-By)*(Cy-By)))/Double_t(((Cx-Bx)*(Cx-Bx)+(Cy-By)*(Cy-By))); - x2 = Double_t(px) - lambda*Double_t(Cx-Bx)-Double_t(Bx); - y2 = Double_t(py) - lambda*Double_t(Cy-By)-Double_t(By); - xy = Double_t((px-Ax)*(px-Ax)+(py-Ay)*(py-Ay)); - if ((TMath::Sqrt(x2*x2+y2*y2) < kMaxDiff/2) && (TMath::Sqrt(xy) <= w*0.3)) { - if (fTextAngle == 0 || fTextAngle == 180) gPad->SetCursor(kArrowVer); - else { - if (fTextAngle == 90 || fTextAngle == 270) gPad->SetCursor(kArrowHor); - else gPad->SetCursor(kHand); - } - hauteur = valign; - largeur = halign; - resize = kTRUE; + theta = fTextAngle; + Size = 0; + pxold = px; + pyold = py; + co = TMath::Cos(fTextAngle*0.017453293); + si = TMath::Sin(fTextAngle*0.017453293); + resize = kFALSE; + turn = kFALSE; + GetControlBox(px1, py1, -theta, CBoxX, CBoxY); + Part = (Int_t)(3*((px-CBoxX[0])*co-(py-CBoxY[0])*si)/ + ((CBoxX[3]-CBoxX[0])*co-(CBoxY[3]-CBoxY[0])*si)); + switch (Part) { + case 0: + if (halign == 3) { + turn = kTRUE; + droite = kTRUE; + gPad->SetCursor(kRotate); + } else { + resize = kTRUE; + hauteur = valign; + largeur = halign; + gPad->SetCursor(kArrowVer); + } break; + case 1: + gPad->SetCursor(kMove); + break; + case 2: + if (halign == 3) { + resize = kTRUE; + hauteur = valign; + largeur = halign; + gPad->SetCursor(kArrowVer); + } else { + turn = kTRUE; + droite = kFALSE; + gPad->SetCursor(kRotate); + } } - gPad->SetCursor(kMove); break; case kButton1Motion: - gVirtualX->DrawText(px1, py1, theta, gVirtualX->GetTextMagnitude(), GetTitle(), TVirtualX::kClear); + PaintControlBox(px1, py1, -theta); if (turn) { norm = TMath::Sqrt(Double_t((py-py1)*(py-py1)+(px-px1)*(px-px1))); if (norm>0) { @@ -309,8 +225,8 @@ void TText::ExecuteEvent(Int_t event, Int_t px, Int_t py) } else if (resize) { - co = TMath::Cos(fTextAngle*0.0175); - si = TMath::Sin(fTextAngle*0.0175); + co = TMath::Cos(fTextAngle*0.017453293); + si = TMath::Sin(fTextAngle*0.017453293); if (largeur == 1) { switch (valign) { case 1 : Ax = px1; Ay = py1; break; @@ -348,7 +264,7 @@ void TText::ExecuteEvent(Int_t event, Int_t px, Int_t py) dx = px - pxold; px1 += dx; dy = py - pyold; py1 += dy; } - gVirtualX->DrawText(px1, py1, theta, gVirtualX->GetTextMagnitude(), GetTitle(), TVirtualX::kClear); + PaintControlBox(px1, py1, -theta); pxold = px; pyold = py; break; @@ -366,11 +282,9 @@ void TText::ExecuteEvent(Int_t event, Int_t px, Int_t py) } fTextAngle = theta; gPad->Modified(kTRUE); - gVirtualX->SetTextColor(-1); break; case kButton1Locate: - ExecuteEvent(kButton1Down, px, py); while (1) { @@ -387,6 +301,91 @@ void TText::ExecuteEvent(Int_t event, Int_t px, Int_t py) } } +//______________________________________________________________________________ +void TText::GetControlBox(Int_t x, Int_t y, Double_t theta, + Int_t CBoxX[4], Int_t CBoxY[4]) +{ + // Return the text control box. The text position coordinates is (x,y) and + // the text angle is theta. The control box coordinates are returned in CBoxX + // and CBoxY. + + Short_t halign = fTextAlign/10; // horizontal alignment + Short_t valign = fTextAlign - 10*halign; // vertical alignment + UInt_t CBoxW, CBoxH; // control box width and heigh + UInt_t Dx = 0, Dy = 0; // delta along x and y to align the box + + GetBoundingBox(CBoxW, CBoxH); + + // compute the translations (Dx, Dy) required by the alignments + switch (halign) { + case 1 : Dx = 0 ; break; + case 2 : Dx = CBoxW/2; break; + case 3 : Dx = CBoxW ; break; + } + switch (valign) { + case 1 : Dy = 0 ; break; + case 2 : Dy = CBoxH/2; break; + case 3 : Dy = CBoxH ; break; + } + + // compute the control box coordinates before rotation + CBoxX[0] = x-Dx; + CBoxY[0] = y+Dy; + CBoxX[1] = x-Dx; + CBoxY[1] = y-CBoxH+Dy; + CBoxX[2] = x+CBoxW-Dx; + CBoxY[2] = y-CBoxH+Dy; + CBoxX[3] = x+CBoxW-Dx; + CBoxY[3] = y+Dy; + + // rotate the control box if needed + if (theta) { + Double_t cosTheta = TMath::Cos(theta*0.017453293); + Double_t sinTheta = TMath::Sin(theta*0.017453293); + for (int i=0; i<4 ; i++) { + Int_t HCBoxX = CBoxX[i]; + Int_t HCBoxY = CBoxY[i]; + CBoxX[i] = (Int_t)((HCBoxX-x)*cosTheta-(HCBoxY-y)*sinTheta+x); + CBoxY[i] = (Int_t)((HCBoxX-x)*sinTheta+(HCBoxY-y)*cosTheta+y); + } + } +} + +//______________________________________________________________________________ +void TText::GetBoundingBox(UInt_t &w, UInt_t &h) +{ + // Return text size in pixels + + if (TTF::IsInitialized() || gPad->IsBatch()) { + TTF::GetTextExtent(w, h, (char*)GetTitle()); + } else { + gVirtualX->GetTextExtent(w, h, (char*)GetTitle()); + } +} + +//______________________________________________________________________________ +void TText::GetTextExtent(UInt_t &w, UInt_t &h, const char *text) const +{ + // Return text extent for string text + // in w return total text width + // in h return text height + + Double_t wh = (Double_t)gPad->XtoPixel(gPad->GetX2()); + Double_t hh = (Double_t)gPad->YtoPixel(gPad->GetY1()); + Double_t tsize; + if (wh < hh) tsize = fTextSize*wh; + else tsize = fTextSize*hh; + + if (gVirtualX->HasTTFonts() || gPad->IsBatch()) { + TTF::SetTextFont(fTextFont); + TTF::SetTextSize(tsize); + TTF::GetTextExtent(w, h, (char*)text); + } else { + gVirtualX->SetTextSize((int)tsize); + gVirtualX->GetTextExtent(w, h, (char*)text); + } +} + //______________________________________________________________________________ void TText::ls(Option_t *) const { @@ -407,6 +406,60 @@ void TText::Paint(Option_t *) else gPad->PaintText(fX,fY,GetTitle()); } +//______________________________________________________________________________ +void TText::PaintControlBox(Int_t x, Int_t y, Double_t theta) +{ + // Paint the text control box. (x,y) are the coordinates where the control + // box should be painted and theta is the angle of the box. + + Int_t CBoxX[4], CBoxY[4]; + Short_t halign = fTextAlign/10; // horizontal alignment + Short_t valign = fTextAlign - 10*halign; // vertical alignment + + GetControlBox(x, y, theta, CBoxX, CBoxY); + // Draw the text control box outline + gVirtualX->SetLineStyle((Style_t)1); + gVirtualX->SetLineWidth(1); + gVirtualX->SetLineColor(1); + gVirtualX->DrawLine(CBoxX[0], CBoxY[0], CBoxX[1], CBoxY[1]); + gVirtualX->DrawLine(CBoxX[1], CBoxY[1], CBoxX[2], CBoxY[2]); + gVirtualX->DrawLine(CBoxX[2], CBoxY[2], CBoxX[3], CBoxY[3]); + gVirtualX->DrawLine(CBoxX[3], CBoxY[3], CBoxX[0], CBoxY[0]); + + // Draw a symbol at the text starting point + TPoint p; + Int_t ix = 0, iy = 0; + switch (halign) { + case 1 : + switch (valign) { + case 1 : ix = 0 ; iy = 0 ; break; + case 2 : ix = 0 ; iy = 1 ; break; + case 3 : ix = 1 ; iy = 1 ; break; + } + break; + case 2 : + switch (valign) { + case 1 : ix = 0 ; iy = 3 ; break; + case 2 : ix = 0 ; iy = 2 ; break; + case 3 : ix = 1 ; iy = 2 ; break; + } + break; + case 3 : + switch (valign) { + case 1 : ix = 3 ; iy = 3 ; break; + case 2 : ix = 2 ; iy = 3 ; break; + case 3 : ix = 2 ; iy = 2 ; break; + } + break; + } + p.fX = (CBoxX[ix]+CBoxX[iy])/2; + p.fY = (CBoxY[ix]+CBoxY[iy])/2; + gVirtualX->SetMarkerColor(1); + gVirtualX->SetMarkerStyle(24); + gVirtualX->SetMarkerSize(0.7); + gVirtualX->DrawPolyMarker(1, &p); +} + //______________________________________________________________________________ void TText::PaintText(Double_t x, Double_t y, const char *text) { diff --git a/gui/src/TGApplication.cxx b/gui/src/TGApplication.cxx index b5daa77f821..ab430d553ad 100644 --- a/gui/src/TGApplication.cxx +++ b/gui/src/TGApplication.cxx @@ -1,4 +1,4 @@ -// @(#)root/gui:$Name: $:$Id: TGApplication.cxx,v 1.3 2002/09/14 20:25:04 rdm Exp $ +// @(#)root/gui:$Name: $:$Id: TGApplication.cxx,v 1.4 2002/10/25 10:40:16 rdm Exp $ // Author: Guy Barrand 30/05/2001 /************************************************************************* @@ -69,13 +69,13 @@ TGApplication::TGApplication(const char *appClassName, if (!fDisplay) gSystem->SetDisplay(); fClient = new TGClient(fDisplay); -#if !defined(WIN32) +#if !defined(R__WIN32) || defined(GDK_WIN32) if (strcmp(appClassName, "proofserv")) { const char *ttpath = gEnv->GetValue("Root.TTFontPath", # ifdef TTFFONTDIR TTFFONTDIR); # else - "$(HOME)/ttf/fonts"); + "$(ROOTSYS)/fonts"); # endif char *ttfont = gSystem->Which(ttpath, "arialbd.ttf", kReadPermission); diff --git a/proofd/src/proofd.cxx b/proofd/src/proofd.cxx index 64c460badac..fbb33fb16b3 100644 --- a/proofd/src/proofd.cxx +++ b/proofd/src/proofd.cxx @@ -1,4 +1,4 @@ -// @(#)root/proofd:$Name: $:$Id: proofd.cxx,v 1.27 2002/03/25 18:18:05 rdm Exp $ +// @(#)root/proofd:$Name: $:$Id: proofd.cxx,v 1.28 2003/01/13 01:33:52 rdm Exp $ // Author: Fons Rademakers 02/02/97 /************************************************************************* @@ -107,9 +107,7 @@ // Protocol changes (see gProtocol): // 6: added support for kerberos5 authentication -#ifdef HAVE_CONFIG #include "config.h" -#endif #include <ctype.h> #include <fcntl.h> @@ -257,7 +255,7 @@ static int setresuid(uid_t r, uid_t e, uid_t) return seteuid(e); } #endif -#if defined(linux) && (__GLIBC__ <= 2 && __GLIBC_MINOR__ <= 2) +#if defined(linux) && !defined(HAS_SETRESUID) extern "C" { int setresgid(gid_t r, gid_t e, gid_t s); int setresuid(uid_t r, uid_t e, uid_t s); diff --git a/rint/src/TRint.cxx b/rint/src/TRint.cxx index 5c9936aa570..08155c2300b 100644 --- a/rint/src/TRint.cxx +++ b/rint/src/TRint.cxx @@ -1,4 +1,4 @@ -// @(#)root/rint:$Name: $:$Id: TRint.cxx,v 1.16 2002/10/29 13:30:00 brun Exp $ +// @(#)root/rint:$Name: $:$Id: TRint.cxx,v 1.17 2002/11/18 23:02:19 rdm Exp $ // Author: Rene Brun 17/02/95 /************************************************************************* @@ -267,7 +267,7 @@ void TRint::PrintLogo() Printf(" * *"); Printf(" * W E L C O M E to R O O T *"); Printf(" * *"); - Printf(" * Version%10s %17s *",root_version,root_date); + Printf(" * Version%10s %17s *", root_version, root_date); // Printf(" * Development version *"); Printf(" * *"); Printf(" * You are welcome to visit our Web site *"); @@ -275,20 +275,20 @@ void TRint::PrintLogo() Printf(" * *"); Printf(" *******************************************"); -#ifdef R__UNIX - if (!strcmp(gVirtualX->GetName(), "X11TTF")) - Printf("\nFreeType Engine v1.x used to render TrueType fonts."); -#endif + if (strstr(gVirtualX->GetName(), "TTF")) { + Int_t major, minor, patch; + //TTF::Version(major, minor, patch); + // avoid dependency on libGraf and hard code, will not change too often + major = 2; minor = 1; patch = 3; + Printf("\nFreeType Engine v%d.%d.%d used to render TrueType fonts.", + major, minor, patch); + } #ifdef _REENTRANT -#ifdef R__UNIX else -#endif printf("\n"); Printf("Compiled for %s with thread support.", gSystem->GetBuildArch()); #else -#ifdef R__UNIX else -#endif printf("\n"); Printf("Compiled for %s.", gSystem->GetBuildArch()); #endif diff --git a/rootd/src/rootd.cxx b/rootd/src/rootd.cxx index 112fe62656d..147ffcfa84e 100644 --- a/rootd/src/rootd.cxx +++ b/rootd/src/rootd.cxx @@ -1,4 +1,4 @@ -// @(#)root/rootd:$Name: $:$Id: rootd.cxx,v 1.47 2002/12/10 02:19:46 rdm Exp $ +// @(#)root/rootd:$Name: $:$Id: rootd.cxx,v 1.48 2003/01/13 01:33:52 rdm Exp $ // Author: Fons Rademakers 11/08/97 /************************************************************************* @@ -160,6 +160,8 @@ // 5 -> 6: added support for kerberos5 authentication // 6 -> 7: added support for kROOTD_BYE and kROOTD_PROTOCOL2 +#include "config.h" + #include <ctype.h> #include <fcntl.h> #include <pwd.h> @@ -357,7 +359,7 @@ static int setresuid(uid_t r, uid_t e, uid_t) return seteuid(e); } #endif -#if defined(linux) && (__GLIBC__ <= 2 && __GLIBC_MINOR__ <= 2) +#if defined(linux) && !defined(HAS_SETRESUID) extern "C" { int setresgid(gid_t r, gid_t e, gid_t s); int setresuid(uid_t r, uid_t e, uid_t s); diff --git a/win32gdk/inc/GdkConstants.h b/win32gdk/inc/GdkConstants.h index 99b67630763..b4820afc3d8 100644 --- a/win32gdk/inc/GdkConstants.h +++ b/win32gdk/inc/GdkConstants.h @@ -160,6 +160,9 @@ typedef enum { WIN32_GDK_GET_WIN_DC, WIN32_GDK_INIT_PIXEL_FORMAT, WIN32_GDK_QUERY_POINTER1, + WIN32_GDK_VISUAL_GET_BEST, + WIN32_GDK_GET_BEST_DEPTH, + WIN32_GDK_VISUAL_GET_TYPE } EWin32Gdk_Msgs; #endif diff --git a/win32gdk/inc/TGWin32.h b/win32gdk/inc/TGWin32.h index 8df788b8afb..dfa7b47e4a7 100644 --- a/win32gdk/inc/TGWin32.h +++ b/win32gdk/inc/TGWin32.h @@ -1,4 +1,4 @@ -// @(#)root/win32gdk:$Name: $:$Id: TGWin32.h,v 1.3 2002/02/21 11:30:17 rdm Exp $ +// @(#)root/win32gdk:$Name: $:$Id: TGWin32.h,v 1.8 2002/10/25 17:38:00 rdm Exp $ // Author: Rene Brun, Olivier Couet, Fons Rademakers, Bertrand Bellenot 27/11/01 /************************************************************************* @@ -136,10 +136,6 @@ struct XWindow_t { class TGWin32 : public TVirtualX { private: - static LPCRITICAL_SECTION flpCriticalSection; // pointer to critical section object - static DWORD fIDThread; // ID of the separate Thread to work out event loop - HANDLE hGDKThread; - static ThreadParam_t fThreadP; Int_t fMaxNumberOfWindows; //Maximum number of windows XWindow_t *fWindows; //List of windows GdkCursor *fCursors[kNumCursors]; //List of cursors @@ -179,6 +175,13 @@ private: void GdkThread(); protected: + + LPCRITICAL_SECTION flpCriticalSection; // pointer to critical section object + DWORD fIDThread; // ID of the separate Thread to work out event loop + HANDLE hGDKThread; + ThreadParam_t fThreadP; + + GdkVisual *fVisual; GdkColormap *fColormap; //Default colormap, 0 if b/w Int_t fScreenNumber; //Screen number Bool_t fHasTTFonts; //True when TrueType fonts are used @@ -188,8 +191,17 @@ protected: Float_t fCharacterUpX; //Character Up vector along X Float_t fCharacterUpY; //Character Up vector along Y Float_t fTextMagnitude; //Text Magnitude + Int_t fDepth; //Number of color planes + Int_t fRedDiv; //Red value divider, -1 if no TrueColor visual + Int_t fGreenDiv; //Green value divider + Int_t fBlueDiv; //Blue value divider + Int_t fRedShift; //Bits to left shift red, -1 if no TrueColor visual + Int_t fGreenShift; //Bits to left shift green + Int_t fBlueShift; //Bits to left shift blue // needed by TGWin32TTF + Bool_t AllocColor(GdkColormap *cmap, GdkColor *color); + void QueryColors(GdkColormap *cmap, GdkColor *colors, Int_t ncolors); XWindow_t *GetCurrentWindow() const; GdkGC *GetGC(Int_t which) const; diff --git a/win32gdk/src/GdkThread.cxx b/win32gdk/src/GdkThread.cxx index 76ff24648c1..a837a524187 100644 --- a/win32gdk/src/GdkThread.cxx +++ b/win32gdk/src/GdkThread.cxx @@ -124,7 +124,7 @@ void TGWin32::GdkThread( ) PeekMessage(&msg, NULL, WM_USER, WM_USER, PM_NOREMOVE); ReleaseSemaphore(fThreadP.hThrSem, 1, NULL); while(!EndLoop) { - erret = GetMessage(&msg, NULL, WIN32_GDK_INIT, WIN32_GDK_QUERY_POINTER1); + erret = GetMessage(&msg, NULL, WIN32_GDK_INIT, WIN32_GDK_VISUAL_GET_TYPE); if (erret <= 0) EndLoop = TRUE; switch (msg.message) { case WIN32_GDK_INIT: @@ -986,6 +986,17 @@ void TGWin32::GdkThread( ) fThreadP.iRet = -2; } break; + case WIN32_GDK_VISUAL_GET_BEST: + fThreadP.pRet = gdk_visual_get_best(); + break; + + case WIN32_GDK_GET_BEST_DEPTH: + fThreadP.iRet = gdk_visual_get_best_depth(); + break; + + case WIN32_GDK_VISUAL_GET_TYPE: + fThreadP.iRet = gdk_visual_get_best_type(); + break; } ReleaseSemaphore(fThreadP.hThrSem, 1, NULL); diff --git a/win32gdk/src/TGWin32.cxx b/win32gdk/src/TGWin32.cxx index 7a360d246a4..e9bb15d951c 100644 --- a/win32gdk/src/TGWin32.cxx +++ b/win32gdk/src/TGWin32.cxx @@ -1,4 +1,4 @@ -// @(#)root/win32gdk:$Name: $:$Id: TGWin32.cxx,v 1.13 2002/12/10 13:26:33 brun Exp $ +// @(#)root/win32gdk:$Name: $:$Id: TGWin32.cxx,v 1.14 2002/12/16 08:13:48 brun Exp $ // Author: Rene Brun, Olivier Couet, Fons Rademakers, Bertrand Bellenot 27/11/01 /************************************************************************* @@ -324,11 +324,6 @@ extern Int_t _lookup_string(Event_t * event, char *buf, Int_t buflen); ClassImp(TGWin32) -LPCRITICAL_SECTION TGWin32::flpCriticalSection; // pointer to critical section object -DWORD TGWin32::fIDThread; // ID of the separate Thread to work out event loop -ThreadParam_t TGWin32::fThreadP; - - //______________________________________________________________________________ TGWin32::TGWin32() { @@ -375,7 +370,7 @@ TGWin32::TGWin32(const char *name, const char *title):TVirtualX(name, } /* fThreadP.hThrSem = CreateSemaphore(NULL, 0, 1, NULL); - hGDKThread = (HANDLE)_beginthreadex( NULL, 0, &HandleGDKThread, (LPVOID) &pThreadP, + hGDKThread = (HANDLE)_beginthreadex( NULL, 0, &HandleGDKThread, (LPVOID) &pThreadP, 0, (unsigned int *) &fIDThread ); WaitForSingleObject(fThreadP.hThrSem, INFINITE); */ @@ -426,46 +421,99 @@ TGWin32::TGWin32(const char *name, const char *title):TVirtualX(name, } //______________________________________________________________________________ -TGWin32::TGWin32(const TGWin32 & org) +TGWin32::TGWin32(const TGWin32 &org) : TVirtualX(org) { // Copy constructor. Currently only used by TGWin32TTF. - int i; + Int_t i; - fScreenNumber = org.fScreenNumber; - fColormap = org.fColormap; - fHasTTFonts = org.fHasTTFonts; - fTextAlignH = org.fTextAlignH; - fTextAlignV = org.fTextAlignV; - fTextAlign = org.fTextAlign; + fScreenNumber = org.fScreenNumber; + fColormap = org.fColormap; + fHasTTFonts = org.fHasTTFonts; + fTextAlignH = org.fTextAlignH; + fTextAlignV = org.fTextAlignV; + fTextAlign = org.fTextAlign; fTextMagnitude = org.fTextMagnitude; - fCharacterUpX = org.fCharacterUpX; - fCharacterUpY = org.fCharacterUpY; - fDrawMode = org.fDrawMode; + fCharacterUpX = org.fCharacterUpX; + fCharacterUpY = org.fCharacterUpY; + fDrawMode = org.fDrawMode; + fRedDiv = org.fRedDiv; + fGreenDiv = org.fGreenDiv; + fBlueDiv = org.fBlueDiv; + fRedShift = org.fRedShift; + fGreenShift = org.fGreenShift; + fBlueShift = org.fBlueShift; + fVisual = org.fVisual; + fColormap = org.fColormap; + fDepth = org.fDepth; fMaxNumberOfWindows = org.fMaxNumberOfWindows; //fWindows = new XWindow_t[fMaxNumberOfWindows]; fWindows = (XWindow_t*) ::operator new(fMaxNumberOfWindows*sizeof(XWindow_t)); for (i = 0; i < fMaxNumberOfWindows; i++) { - fWindows[i].open = org.fWindows[i].open; + fWindows[i].open = org.fWindows[i].open; fWindows[i].double_buffer = org.fWindows[i].double_buffer; - fWindows[i].ispixmap = org.fWindows[i].ispixmap; - fWindows[i].drawing = org.fWindows[i].drawing; - fWindows[i].window = org.fWindows[i].window; - fWindows[i].buffer = org.fWindows[i].buffer; - fWindows[i].width = org.fWindows[i].width; - fWindows[i].height = org.fWindows[i].height; - fWindows[i].clip = org.fWindows[i].clip; - fWindows[i].xclip = org.fWindows[i].xclip; - fWindows[i].yclip = org.fWindows[i].yclip; - fWindows[i].wclip = org.fWindows[i].wclip; - fWindows[i].hclip = org.fWindows[i].hclip; - fWindows[i].new_colors = org.fWindows[i].new_colors; - fWindows[i].ncolors = org.fWindows[i].ncolors; + fWindows[i].ispixmap = org.fWindows[i].ispixmap; + fWindows[i].drawing = org.fWindows[i].drawing; + fWindows[i].window = org.fWindows[i].window; + fWindows[i].buffer = org.fWindows[i].buffer; + fWindows[i].width = org.fWindows[i].width; + fWindows[i].height = org.fWindows[i].height; + fWindows[i].clip = org.fWindows[i].clip; + fWindows[i].xclip = org.fWindows[i].xclip; + fWindows[i].yclip = org.fWindows[i].yclip; + fWindows[i].wclip = org.fWindows[i].wclip; + fWindows[i].hclip = org.fWindows[i].hclip; + fWindows[i].new_colors = org.fWindows[i].new_colors; + fWindows[i].ncolors = org.fWindows[i].ncolors; } for (i = 0; i < kNumCursors; i++) fCursors[i] = org.fCursors[i]; + + fThreadP.Drawable = org.fThreadP.Drawable; + fThreadP.GC = org.fThreadP.GC; + fThreadP.pParam = org.fThreadP.pParam; + fThreadP.pParam1 = org.fThreadP.pParam1; + fThreadP.pParam2 = org.fThreadP.pParam2; + fThreadP.iParam = org.fThreadP.iParam; + fThreadP.iParam1 = org.fThreadP.iParam1; + fThreadP.iParam2 = org.fThreadP.iParam2; + fThreadP.uiParam = org.fThreadP.uiParam; + fThreadP.uiParam1 = org.fThreadP.uiParam1; + fThreadP.uiParam2 = org.fThreadP.uiParam2; + fThreadP.lParam = org.fThreadP.lParam; + fThreadP.lParam1 = org.fThreadP.lParam1; + fThreadP.lParam2 = org.fThreadP.lParam2; + fThreadP.x = org.fThreadP.x; + fThreadP.x1 = org.fThreadP.x1; + fThreadP.x2 = org.fThreadP.x2; + fThreadP.y = org.fThreadP.y; + fThreadP.y1 = org.fThreadP.y1; + fThreadP.y2 = org.fThreadP.y2; + fThreadP.w = org.fThreadP.w; + fThreadP.h = org.fThreadP.h; + fThreadP.xpos = org.fThreadP.xpos; + fThreadP.ypos = org.fThreadP.ypos; + fThreadP.angle1 = org.fThreadP.angle1; + fThreadP.angle2 = org.fThreadP.angle2; + fThreadP.bFill = org.fThreadP.bFill; + fThreadP.sRet = org.fThreadP.sRet; + fThreadP.iRet = org.fThreadP.iRet; + fThreadP.iRet1 = org.fThreadP.iRet1; + fThreadP.uiRet = org.fThreadP.uiRet; + fThreadP.uiRet1 = org.fThreadP.uiRet1; + fThreadP.lRet = org.fThreadP.lRet; + fThreadP.lRet1 = org.fThreadP.lRet1; + fThreadP.pRet = org.fThreadP.pRet; + fThreadP.pRet1 = org.fThreadP.pRet1; + + fThreadP.hThrSem = CreateSemaphore(0, 0, 1, 0); + hGDKThread = CreateThread(0, 0, this->ThreadStub, this, 0, &fIDThread); + //WaitForSingleObject(fThreadP.hThrSem, INFINITE); + flpCriticalSection = new CRITICAL_SECTION; + InitializeCriticalSection(flpCriticalSection); + gIDThread = fIDThread; } //______________________________________________________________________________ @@ -478,10 +526,8 @@ TGWin32::~TGWin32() if (hThread2) CloseHandle(hThread2); // Splash Screen Thread Handle if (fIDThread) { - PostThreadMessage(fIDThread, WIN32_GDK_EXIT, 0, 0L); - WaitForSingleObject(fThreadP.hThrSem, INFINITE); + if (hGDKThread) CloseHandle(hGDKThread); CloseHandle(fThreadP.hThrSem); - CloseHandle(hGDKThread); } DeleteCriticalSection(flpCriticalSection); @@ -494,7 +540,7 @@ Bool_t TGWin32::Init() EnterCriticalSection(flpCriticalSection); if (!gdk_initialized) { - PostThreadMessage(fIDThread, WIN32_GDK_INIT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_INIT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); if(!fThreadP.iRet) { LeaveCriticalSection(flpCriticalSection); @@ -505,7 +551,7 @@ Bool_t TGWin32::Init() if (!clipboard_atom) { fThreadP.iParam = kFALSE; sprintf(fThreadP.sParam,"CLIPBOARD"); - PostThreadMessage(fIDThread, WIN32_GDK_ATOM, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_ATOM, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); clipboard_atom = (GdkAtom)fThreadP.ulRet; } @@ -515,6 +561,78 @@ Bool_t TGWin32::Init() return kTRUE; } +//______________________________________________________________________________ +Bool_t TGWin32::AllocColor(GdkColormap *cmap, GdkColor *color) +{ + // Allocate color in colormap. If we are on an <= 8 plane machine + // we will use XAllocColor. If we are on a >= 15 (15, 16 or 24) plane + // true color machine we will calculate the pixel value using: + // for 15 and 16 bit true colors have 6 bits precision per color however + // only the 5 most significant bits are used in the color index. + // Except for 16 bits where green uses all 6 bits. I.e.: + // 15 bits = rrrrrgggggbbbbb + // 16 bits = rrrrrggggggbbbbb + // for 24 bits each r, g and b are represented by 8 bits. + // + // Since all colors are set with a max of 65535 (16 bits) per r, g, b + // we just right shift them by 10, 11 and 10 bits for 16 planes, and + // (10, 10, 10 for 15 planes) and by 8 bits for 24 planes. + // Returns kFALSE in case color allocation failed. + + EnterCriticalSection(flpCriticalSection); + if (fRedDiv == -1) { + fThreadP.pParam = cmap; + fThreadP.pRet = color; + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_ALLOC, 0, 0L); + WaitForSingleObject(fThreadP.hThrSem, INFINITE); + if (fThreadP.iRet) { + LeaveCriticalSection(flpCriticalSection); + return kTRUE; + } + } else { + color->pixel = (color->red >> fRedDiv) << fRedShift | + (color->green >> fGreenDiv) << fGreenShift | + (color->blue >> fBlueDiv) << fBlueShift; + LeaveCriticalSection(flpCriticalSection); + return kTRUE; + } + LeaveCriticalSection(flpCriticalSection); + return kFALSE; +} + +//______________________________________________________________________________ +void TGWin32::QueryColors(GdkColormap *cmap, GdkColor *color, Int_t ncolors) +{ + // Returns the current RGB value for the pixel in the XColor structure. + EnterCriticalSection(flpCriticalSection); + if (fRedDiv == -1) { + fThreadP.pParam = cmap; + fThreadP.pRet = NULL; + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_NEW, 0, 0L); + WaitForSingleObject(fThreadP.hThrSem, INFINITE); + GdkColorContext *cc = (GdkColorContext *)fThreadP.pRet; + + fThreadP.pParam = cc; + fThreadP.pRet = color; + fThreadP.iParam = ncolors; + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_QUERY_COLORS, 0, 0L); + WaitForSingleObject(fThreadP.hThrSem, INFINITE); + } else { + ULong_t r, g, b; + for (Int_t i = 0; i < ncolors; i++) { + r = (color[i].pixel & fVisual->red_mask) >> fRedShift; + color[i].red = UShort_t(r*kBIGGEST_RGB_VALUE/(fVisual->red_mask >> fRedShift)); + + g = (color[i].pixel & fVisual->green_mask) >> fGreenShift; + color[i].green = UShort_t(g*kBIGGEST_RGB_VALUE/(fVisual->green_mask >> fGreenShift)); + + b = (color[i].pixel & fVisual->blue_mask) >> fBlueShift; + color[i].blue = UShort_t(b*kBIGGEST_RGB_VALUE/(fVisual->blue_mask >> fBlueShift)); + } + } + LeaveCriticalSection(flpCriticalSection); +} + //______________________________________________________________________________ void TGWin32::ClearPixmap(GdkDrawable * pix) { @@ -526,7 +644,7 @@ void TGWin32::ClearPixmap(GdkDrawable * pix) int ww, hh, border, depth; fThreadP.Drawable = (GdkDrawable *) pix; - PostThreadMessage(fIDThread, WIN32_GDK_DRAWABLE_GET_SIZE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAWABLE_GET_SIZE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ww = fThreadP.w; hh = fThreadP.h; @@ -538,10 +656,10 @@ void TGWin32::ClearPixmap(GdkDrawable * pix) fThreadP.w = ww; fThreadP.h = hh; fThreadP.bFill = kTRUE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); SetColor(gGCpxmp, 1); - PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -558,11 +676,11 @@ void TGWin32::ClearWindow() fThreadP.color.red = gColors[0].color.red; fThreadP.color.green = gColors[0].color.green; fThreadP.color.blue = gColors[0].color.blue; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_BACKGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_BACKGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - PostThreadMessage(fIDThread, WIN32_GDK_WIN_CLEAR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_CLEAR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { SetColor(gGCpxmp, 0); @@ -573,7 +691,7 @@ void TGWin32::ClearWindow() fThreadP.w = gCws->width; fThreadP.h = gCws->height; fThreadP.bFill = kFALSE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); SetColor(gGCpxmp, 1); } @@ -609,27 +727,27 @@ void TGWin32::CloseWindow1() fThreadP.Drawable = (GdkDrawable *) gCws->window; if (gCws->ispixmap) - PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); else - PostThreadMessage(fIDThread, WIN32_GDK_WIN_DESTROY, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_DESTROY, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); if (gCws->buffer) { fThreadP.Drawable = (GdkDrawable *) gCws->buffer; - PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } if (gCws->new_colors) { fThreadP.pParam = fColormap; fThreadP.pParam2 = gCws->new_colors; fThreadP.iParam = gCws->ncolors; - PostThreadMessage(fIDThread, WIN32_GDK_CMAP_FREE_COLORS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CMAP_FREE_COLORS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); delete[]gCws->new_colors; gCws->new_colors = 0; } - PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gCws->open = 0; @@ -664,7 +782,7 @@ void TGWin32::CopyPixmap(int wid, int xpos, int ypos) fThreadP.xpos = xpos; fThreadP.ypos = ypos; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_COPY_AREA, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_COPY_AREA, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -680,7 +798,7 @@ void TGWin32::CopyWindowtoPixmap(GdkDrawable * pix, int xpos, int ypos) int ww, hh, border, depth; fThreadP.Drawable = (GdkDrawable *) pix; - PostThreadMessage(fIDThread, WIN32_GDK_DRAWABLE_GET_SIZE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAWABLE_GET_SIZE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ww = fThreadP.w; hh = fThreadP.h; @@ -695,10 +813,10 @@ void TGWin32::CopyWindowtoPixmap(GdkDrawable * pix, int xpos, int ypos) fThreadP.xpos = xpos; fThreadP.ypos = ypos; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_COPY_AREA, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_COPY_AREA, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -722,14 +840,14 @@ void TGWin32::DrawBox(int x1, int y1, int x2, int y2, EBoxMode mode) case kHollow: fThreadP.GC = gGCline; fThreadP.bFill = kFALSE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; case kFilled: fThreadP.GC = gGCfill; fThreadP.bFill = kTRUE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; @@ -773,7 +891,7 @@ void TGWin32::DrawCellArray(int x1, int y1, int x2, int y2, int nx, int ny, fThreadP.color.red = gColors[icol].color.red; fThreadP.color.green = gColors[icol].color.green; fThreadP.color.blue = gColors[icol].color.blue; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); current_icol = icol; } @@ -783,7 +901,7 @@ void TGWin32::DrawCellArray(int x1, int y1, int x2, int y2, int nx, int ny, fThreadP.w = w; fThreadP.h = h; fThreadP.bFill = kTRUE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); iy = iy - h; } @@ -814,11 +932,11 @@ void TGWin32::DrawFillArea(int n, TPoint * xyt) fThreadP.iParam = n; if (gFillHollow) { - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { - PostThreadMessage(fIDThread, WIN32_GDK_FILL_POLYGON, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FILL_POLYGON, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } delete[](GdkPoint *) xy; @@ -840,7 +958,7 @@ void TGWin32::DrawLine(int x1, int y1, int x2, int y2) fThreadP.y2 = y2; if (gLineStyle == GDK_LINE_SOLID) { fThreadP.GC = gGCline; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { @@ -852,10 +970,10 @@ void TGWin32::DrawLine(int x1, int y1, int x2, int y2) fThreadP.GC = gGCdash; fThreadP.iParam = gDashOffset; fThreadP.iParam2 = sizeof(gDashList); - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_DASHES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_DASHES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); + + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } LeaveCriticalSection(flpCriticalSection); @@ -885,7 +1003,7 @@ void TGWin32::DrawPolyLine(int n, TPoint * xyt) if (n > 1) { if (gLineStyle == GDK_LINE_SOLID) { fThreadP.GC = gGCline; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { @@ -897,11 +1015,11 @@ void TGWin32::DrawPolyLine(int n, TPoint * xyt) fThreadP.GC = gGCdash; fThreadP.iParam = gDashOffset; fThreadP.iParam2 = sizeof(gDashList); - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_DASHES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_DASHES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.iParam = n; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); // calculate length of line to update dash offset @@ -920,11 +1038,11 @@ void TGWin32::DrawPolyLine(int n, TPoint * xyt) int px, py; px = xy[0].x; py = xy[0].y; - + fThreadP.x = px; fThreadP.y = py; fThreadP.GC = gLineStyle == GDK_LINE_SOLID ? gGCline : gGCdash; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_POINT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_POINT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } delete[](GdkPoint *) xy; @@ -953,7 +1071,7 @@ void TGWin32::DrawPolyMarker(int n, TPoint * xyt) fThreadP.iParam = n; if (gMarker.n <= 0) { - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_POINTS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_POINTS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { @@ -974,13 +1092,13 @@ void TGWin32::DrawPolyMarker(int n, TPoint * xyt) case 0: // hollow circle fThreadP.bFill = kFALSE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_ARC, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_ARC, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; case 1: // filled circle fThreadP.bFill = kTRUE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_ARC, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_ARC, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; @@ -996,7 +1114,7 @@ void TGWin32::DrawPolyMarker(int n, TPoint * xyt) fThreadP.GC = gGCmark; fThreadP.pParam = gMarker.xy; fThreadP.iParam = gMarker.n; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { @@ -1004,7 +1122,7 @@ void TGWin32::DrawPolyMarker(int n, TPoint * xyt) fThreadP.GC = gGCmark; fThreadP.pParam = gMarker.xy; fThreadP.iParam = gMarker.n; - PostThreadMessage(fIDThread, WIN32_GDK_FILL_POLYGON, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FILL_POLYGON, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } for (i = 0; i < gMarker.n; i++) { @@ -1022,7 +1140,7 @@ void TGWin32::DrawPolyMarker(int n, TPoint * xyt) fThreadP.x2 = xy[m].x + gMarker.xy[i + 1].x; fThreadP.y2 = xy[m].y + gMarker.xy[i + 1].y; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } break; @@ -1061,7 +1179,7 @@ void TGWin32::DrawText(int x, int y, float angle, float mgn, avg_width[10]; fThreadP.pParam = gTextFont; - PostThreadMessage(fIDThread, WIN32_GDK_FONT_FULLNAME_GET, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONT_FULLNAME_GET, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); sprintf(old_font_name,"%s",fThreadP.sRet); sprintf(font_name,"%s",fThreadP.sRet); @@ -1070,7 +1188,7 @@ void TGWin32::DrawText(int x, int y, float angle, float mgn, // gchar *font_name = gdk_font_full_name_get(gTextFont); fThreadP.pParam = gTextFont; - PostThreadMessage(fIDThread, WIN32_GDK_FONT_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONT_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); sscanf(font_name, "-%30[^-]-%100[^-]-%30[^-]-%30[^-]-%30[^-]-%n", @@ -1102,13 +1220,13 @@ void TGWin32::DrawText(int x, int y, float angle, float mgn, fThreadP.pRet = NULL; sprintf(fThreadP.sParam,"%s",font_name); - PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gTextFont = (GdkFont *)fThreadP.pRet; fThreadP.GC = (GdkGC *) gGCtext; fThreadP.uiParam = fTextAlign; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_TEXT_ALIGN, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_TEXT_ALIGN, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); old_align = fThreadP.uiRet; @@ -1125,23 +1243,23 @@ void TGWin32::DrawText(int x, int y, float angle, float mgn, fThreadP.y = y2; sprintf(fThreadP.sParam,"%s",text); fThreadP.iParam = length; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_TEXT_WC, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_TEXT_WC, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } fThreadP.GC = (GdkGC *) gGCtext; fThreadP.uiParam = 0; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_TEXT_ALIGN, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_TEXT_ALIGN, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.pParam = gTextFont; - PostThreadMessage(fIDThread, WIN32_GDK_FONT_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONT_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); sprintf(fThreadP.sParam,"%s",old_font_name); fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gTextFont = (GdkFont *)fThreadP.pRet; - PostThreadMessage(fIDThread, WIN32_GDK_FONT_FULLNAME_FREE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONT_FULLNAME_FREE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -1202,11 +1320,11 @@ void TGWin32::GetGeometry(int wid, int &x, int &y, unsigned int &w, if (wid < 0) { x = 0; y = 0; - - PostThreadMessage(fIDThread, WIN32_GDK_SCREEN_WIDTH, 0, 0L); + + PostThreadMessage(fIDThread, WIN32_GDK_SCREEN_WIDTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); w = fThreadP.w; - PostThreadMessage(fIDThread, WIN32_GDK_SCREEN_HEIGHT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_SCREEN_HEIGHT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); h = fThreadP.h; } else { @@ -1216,7 +1334,7 @@ void TGWin32::GetGeometry(int wid, int &x, int &y, unsigned int &w, gTws = &fWindows[wid]; fThreadP.Drawable = (GdkDrawable *) gTws->window; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_GEOMETRY, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_GEOMETRY, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); x = fThreadP.x; y = fThreadP.y; @@ -1224,7 +1342,7 @@ void TGWin32::GetGeometry(int wid, int &x, int &y, unsigned int &w, height = fThreadP.h; fThreadP.Drawable = (GdkDrawable *) gTws->window; - PostThreadMessage(fIDThread, WIN32_GDK_GET_DESK_ORIGIN, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_DESK_ORIGIN, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); x = fThreadP.x; y = fThreadP.y; @@ -1253,7 +1371,7 @@ void TGWin32::GetPlanes(int &nplanes) // Get maximum number of planes. EnterCriticalSection(flpCriticalSection); - PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); nplanes = fThreadP.iRet; LeaveCriticalSection(flpCriticalSection); @@ -1281,11 +1399,11 @@ void TGWin32::GetTextExtent(unsigned int &w, unsigned int &h, char *mess) fThreadP.pParam = gTextFont; fThreadP.iParam = strlen(mess); sprintf(fThreadP.sParam,"%s",mess); - PostThreadMessage(fIDThread, WIN32_GDK_GET_TEXT_WIDTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_TEXT_WIDTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); w = fThreadP.iRet; - PostThreadMessage(fIDThread, WIN32_GDK_GET_TEXT_HEIGHT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_TEXT_HEIGHT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); h = fThreadP.iRet; @@ -1316,7 +1434,7 @@ void TGWin32::MoveWindow(int wid, int x, int y) fThreadP.Drawable = (GdkDrawable *) gTws->window; fThreadP.x = x; fThreadP.y = y; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_MOVE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_MOVE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -1335,15 +1453,23 @@ Int_t TGWin32::OpenDisplay() fScreenNumber = 0; //DefaultScreen(fDisplay); + PostThreadMessage(fIDThread, WIN32_GDK_VISUAL_GET_BEST, 0, 0L); + WaitForSingleObject(fThreadP.hThrSem, INFINITE); + fVisual = (GdkVisual *) fThreadP.pRet; + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CMAP_GET_SYSTEM, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CMAP_GET_SYSTEM, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fColormap = (GdkColormap *) fThreadP.pRet; + PostThreadMessage(fIDThread, WIN32_GDK_GET_BEST_DEPTH, 0, 0L); + WaitForSingleObject(fThreadP.hThrSem, INFINITE); + fDepth = fThreadP.iRet; + gColors[1].defined = 1; // default foreground fThreadP.pParam = fColormap; - PostThreadMessage(fIDThread, WIN32_GDK_COLOR_BLACK, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_BLACK, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gColors[1].color.pixel = fThreadP.color.pixel; gColors[1].color.red = fThreadP.color.red; @@ -1351,9 +1477,9 @@ Int_t TGWin32::OpenDisplay() gColors[1].color.blue = fThreadP.color.blue; gColors[0].defined = 1; // default background - + fThreadP.pParam = fColormap; - PostThreadMessage(fIDThread, WIN32_GDK_COLOR_WHITE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_WHITE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gColors[0].color.pixel = fThreadP.color.pixel; gColors[0].color.red = fThreadP.color.red; @@ -1365,7 +1491,7 @@ Int_t TGWin32::OpenDisplay() fThreadP.pRet = NULL; fThreadP.pParam = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_GC_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gGClist[i] = (GdkGC *) fThreadP.pRet; @@ -1374,7 +1500,7 @@ Int_t TGWin32::OpenDisplay() fThreadP.color.red = gColors[1].color.red ; fThreadP.color.green = gColors[1].color.green ; fThreadP.color.blue = gColors[1].color.blue ; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.GC = gGClist[i]; @@ -1382,7 +1508,7 @@ Int_t TGWin32::OpenDisplay() fThreadP.color.red = gColors[0].color.red ; fThreadP.color.green = gColors[0].color.green ; fThreadP.color.blue = gColors[0].color.blue ; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } @@ -1395,7 +1521,7 @@ Int_t TGWin32::OpenDisplay() gGCpxmp = gGClist[6]; // Pixmap management fThreadP.GC = gGCtext; - PostThreadMessage(fIDThread, WIN32_GDK_GC_GET_VALUES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_GET_VALUES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.GC = gGCinvt; @@ -1403,7 +1529,7 @@ Int_t TGWin32::OpenDisplay() fThreadP.color.red = fThreadP.gcvals.background.red ; fThreadP.color.green = fThreadP.gcvals.background.green ; fThreadP.color.blue = fThreadP.gcvals.background.blue ; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.GC = gGCinvt; @@ -1411,21 +1537,21 @@ Int_t TGWin32::OpenDisplay() fThreadP.color.red = fThreadP.gcvals.foreground.red ; fThreadP.color.green = fThreadP.gcvals.foreground.green ; fThreadP.color.blue = fThreadP.gcvals.foreground.blue ; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); // Create input echo graphic context fThreadP.pParam = fColormap; - PostThreadMessage(fIDThread, WIN32_GDK_COLOR_BLACK, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_BLACK, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.gcvals.foreground.pixel = fThreadP.color.pixel; fThreadP.gcvals.foreground.red = fThreadP.color.red ; fThreadP.gcvals.foreground.green = fThreadP.color.green; fThreadP.gcvals.foreground.blue = fThreadP.color.blue ; - + fThreadP.pParam = fColormap; - PostThreadMessage(fIDThread, WIN32_GDK_COLOR_WHITE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_WHITE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.gcvals.background.pixel = fThreadP.color.pixel; fThreadP.gcvals.background.red = fThreadP.color.red ; @@ -1439,10 +1565,10 @@ Int_t TGWin32::OpenDisplay() fThreadP.iParam = (GDK_GC_FOREGROUND | GDK_GC_BACKGROUND | GDK_GC_FUNCTION | GDK_GC_SUBWINDOW); fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_GC_NEW_WITH_VAL, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_NEW_WITH_VAL, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gGCecho = (GdkGC *) fThreadP.pRet; - + // Load a default Font static int isdisp = 0; if (!isdisp) { @@ -1453,42 +1579,42 @@ Int_t TGWin32::OpenDisplay() fThreadP.pRet = NULL; sprintf(fThreadP.sParam,"*Arial*"); - PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fontlist = (char **)fThreadP.pRet; fontcount = fThreadP.iRet; - + if (fontcount != 0) { fThreadP.pRet = NULL; sprintf(fThreadP.sParam,"%s",fontlist[0]); - PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gFont[gCurrentFontNumber].id = (GdkFont *)fThreadP.pRet; gTextFont = gFont[gCurrentFontNumber].id; strcpy(gFont[gCurrentFontNumber].name, "Arial"); gCurrentFontNumber++; fThreadP.pParam = fontlist; - PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_FREE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_FREE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { // emergency: try fixed font sprintf(fThreadP.sParam,"*fixed*"); fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fontlist = (char **) fThreadP.pRet; fontcount = fThreadP.iRet; if (fontcount != 0) { sprintf(fThreadP.sParam,"%s",fontlist[0]); fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gFont[gCurrentFontNumber].id = (GdkFont *)fThreadP.pRet; gTextFont = gFont[gCurrentFontNumber].id; strcpy(gFont[gCurrentFontNumber].name, "fixed"); gCurrentFontNumber++; fThreadP.pParam = fontlist; - PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_FREE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_FREE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { Warning("OpenDisplay", "no default font loaded"); @@ -1502,113 +1628,149 @@ Int_t TGWin32::OpenDisplay() fThreadP.w = 16; fThreadP.h = 16; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_BMP_CREATE_FROM_DATA, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_BMP_CREATE_FROM_DATA, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); pixmp1 = (GdkPixmap *) fThreadP.pRet; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_BMP_CREATE_FROM_DATA, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_BMP_CREATE_FROM_DATA, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); pixmp2 = (GdkPixmap *) fThreadP.pRet; fThreadP.Drawable = (GdkDrawable *) pixmp1; fThreadP.pParam = pixmp2; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW_FROM_PIXMAP, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW_FROM_PIXMAP, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gNullCursor = (GdkCursor *) fThreadP.pRet; // Create cursors fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_BOTTOM_LEFT_CORNER, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_BOTTOM_LEFT_CORNER, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kBottomLeft] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_BOTTOM_RIGHT_CORNER, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_BOTTOM_RIGHT_CORNER, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kBottomRight] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_TOP_LEFT_CORNER, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_TOP_LEFT_CORNER, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kTopLeft] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_TOP_RIGHT_CORNER, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_TOP_RIGHT_CORNER, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kTopRight] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_BOTTOM_SIDE, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_BOTTOM_SIDE, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kBottomSide] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_LEFT_SIDE, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_LEFT_SIDE, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kLeftSide] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_TOP_SIDE, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_TOP_SIDE, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kTopSide] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_RIGHT_SIDE, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_RIGHT_SIDE, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kRightSide] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_FLEUR, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_FLEUR, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kMove] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_CROSSHAIR, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_CROSSHAIR, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kCross] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_SB_H_DOUBLE_ARROW, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_SB_H_DOUBLE_ARROW, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kArrowHor] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_SB_V_DOUBLE_ARROW, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_SB_V_DOUBLE_ARROW, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kArrowVer] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_HAND2, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_HAND2, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kHand] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_EXCHANGE, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_EXCHANGE, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kRotate] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_LEFT_PTR, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_LEFT_PTR, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kPointer] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_ARROW, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_ARROW, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kArrowRight] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_XTERM, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_XTERM, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kCaret] = (GdkCursor *) fThreadP.pRet; - + fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_WATCH, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_WATCH, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fCursors[kWatch] = (GdkCursor *) fThreadP.pRet; + // Setup color information + fRedDiv = fGreenDiv = fBlueDiv = fRedShift = fGreenShift = fBlueShift = -1; + + PostThreadMessage(fIDThread, WIN32_GDK_VISUAL_GET_TYPE, 0, 0L); + WaitForSingleObject(fThreadP.hThrSem, INFINITE); + + if (fThreadP.iRet == GDK_VISUAL_TRUE_COLOR) { + int i; + for (i = 0; i < int(sizeof(fVisual->blue_mask)*kBitsPerByte); i++) { + if (fBlueShift == -1 && ((fVisual->blue_mask >> i) & 1)) + fBlueShift = i; + if ((fVisual->blue_mask >> i) == 1) { + fBlueDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fBlueShift; + break; + } + } + for (i = 0; i < int(sizeof(fVisual->green_mask)*kBitsPerByte); i++) { + if (fGreenShift == -1 && ((fVisual->green_mask >> i) & 1)) + fGreenShift = i; + if ((fVisual->green_mask >> i) == 1) { + fGreenDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fGreenShift; + break; + } + } + for (i = 0; i < int(sizeof(fVisual->red_mask)*kBitsPerByte); i++) { + if (fRedShift == -1 && ((fVisual->red_mask >> i) & 1)) + fRedShift = i; + if ((fVisual->red_mask >> i) == 1) { + fRedDiv = sizeof(UShort_t)*kBitsPerByte - i - 1 + fRedShift; + break; + } + } + //printf("fRedDiv = %d, fGreenDiv = %d, fBlueDiv = %d, fRedShift = %d, fGreenShift = %d, fBlueShift = %d\n", + // fRedDiv, fGreenDiv, fBlueDiv, fRedShift, fGreenShift, fBlueShift); + } + LeaveCriticalSection(flpCriticalSection); return 0; } @@ -1650,7 +1812,7 @@ Int_t TGWin32::OpenPixmap(unsigned int w, unsigned int h) goto again; } - PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); depth = fThreadP.iRet; fThreadP.Drawable = NULL; @@ -1658,12 +1820,12 @@ Int_t TGWin32::OpenPixmap(unsigned int w, unsigned int h) fThreadP.h = hval; fThreadP.iParam = depth; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gCws->window = (GdkPixmap *) fThreadP.pRet; fThreadP.Drawable = (GdkDrawable *) gCws->window; - PostThreadMessage(fIDThread, WIN32_GDK_DRAWABLE_GET_SIZE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAWABLE_GET_SIZE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ww = fThreadP.w; hh = fThreadP.h; @@ -1671,11 +1833,11 @@ Int_t TGWin32::OpenPixmap(unsigned int w, unsigned int h) for (i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; fThreadP.pParam = None; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } SetColor(gGCpxmp, 0); - + fThreadP.Drawable = (GdkDrawable *) gCws->window; fThreadP.GC = gGCpxmp; fThreadP.x = 0; @@ -1683,9 +1845,9 @@ Int_t TGWin32::OpenPixmap(unsigned int w, unsigned int h) fThreadP.w = ww; fThreadP.h = hh; fThreadP.bFill = kTRUE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - + SetColor(gGCpxmp, 1); // Initialise the window structure @@ -1718,7 +1880,7 @@ Int_t TGWin32::InitWindow(ULong_t win) GdkWindow *wind = (GdkWindow *) win; fThreadP.Drawable = (GdkDrawable *) wind; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_GEOMETRY, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_GEOMETRY, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); xval = fThreadP.x; yval = fThreadP.y; @@ -1766,12 +1928,12 @@ Int_t TGWin32::InitWindow(ULong_t win) fThreadP.xattr.width = wval; fThreadP.xattr.height = hval; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CMAP_GET_SYSTEM, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CMAP_GET_SYSTEM, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.xattr.colormap = (GdkColormap *)fThreadP.pRet; fThreadP.Drawable = (GdkDrawable *) wind; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_GET_VISUAL, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_GET_VISUAL, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.xattr.visual = (GdkVisual *)fThreadP.pRet; fThreadP.xattr.override_redirect = TRUE; @@ -1784,19 +1946,19 @@ Int_t TGWin32::InitWindow(ULong_t win) attr_mask |= GDK_WA_VISUAL; fThreadP.xattr.window_type = GDK_WINDOW_CHILD; - + fThreadP.Drawable = (GdkDrawable *) wind; fThreadP.lParam = attr_mask; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gCws->window = (GdkWindow *) fThreadP.pRet; fThreadP.Drawable = (GdkDrawable *) gCws->window; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_SHOW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_SHOW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - - PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); + + PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); // Initialise the window structure @@ -1824,7 +1986,7 @@ void TGWin32::QueryPointer(int &ix, int &iy) EnterCriticalSection(flpCriticalSection); fThreadP.Drawable = (GdkDrawable *) gCws->window; - PostThreadMessage(fIDThread, WIN32_GDK_QUERY_POINTER, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_QUERY_POINTER, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ix = fThreadP.x; iy = fThreadP.y; @@ -1838,7 +2000,7 @@ void TGWin32::RemovePixmap(GdkDrawable * pix) EnterCriticalSection(flpCriticalSection); fThreadP.Drawable = (GdkDrawable *) pix; - PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -1888,7 +2050,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) if (ctyp > 1) { fThreadP.Drawable = (GdkDrawable *) gCws->window; fThreadP.pParam = gNullCursor; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_CURSOR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_CURSOR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.GC = (GdkGC *) gGCecho; @@ -1896,16 +2058,16 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) fThreadP.color.red = gColors[0].color.red; fThreadP.color.green = gColors[0].color.green; fThreadP.color.blue = gColors[0].color.blue; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_CROSSHAIR, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_CROSSHAIR, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); cursor = (GdkCursor *) fThreadP.pRet; fThreadP.Drawable = (GdkDrawable *) gCws->window; fThreadP.pParam = cursor; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_CURSOR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_CURSOR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } } @@ -1927,13 +2089,13 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) fThreadP.y1 = 0; fThreadP.x2 = xloc; fThreadP.y2 = gCws->height; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.x1 = 0; fThreadP.y1 = yloc; fThreadP.x2 = gCws->width; fThreadP.y2 = yloc; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; @@ -1941,7 +2103,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) radius = (int) TMath::Sqrt((double) ((xloc - xlocp) * (xloc - xlocp) + (yloc - ylocp) * (yloc - ylocp))); - + fThreadP.Drawable = (GdkDrawable *) gCws->window; fThreadP.GC = gGCecho; fThreadP.x = xlocp - radius; @@ -1951,9 +2113,9 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) fThreadP.angle1 = 0; fThreadP.angle2 = 23040; fThreadP.bFill = kFALSE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_ARC, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_ARC, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - + case 4: fThreadP.Drawable = (GdkDrawable *) gCws->window; fThreadP.GC = gGCecho; @@ -1961,7 +2123,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) fThreadP.y1 = ylocp; fThreadP.x2 = xloc; fThreadP.y2 = yloc; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; @@ -1973,7 +2135,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) fThreadP.w = TMath::Abs(xloc - xlocp); fThreadP.h = TMath::Abs(yloc - ylocp); fThreadP.bFill = kFALSE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; @@ -1982,7 +2144,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) } fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_GET_EVENT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_EVENT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); event = (GdkEvent *) fThreadP.pRet; @@ -1998,13 +2160,13 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) fThreadP.y1 = 0; fThreadP.x2 = xloc; fThreadP.y2 = gCws->height; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.x1 = 0; fThreadP.y1 = yloc; fThreadP.x2 = gCws->width; fThreadP.y2 = yloc; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; @@ -2022,7 +2184,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) fThreadP.h = 2 * radius; fThreadP.angle1 = 0; fThreadP.angle2 = 23040; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_ARC, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_ARC, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); case 4: @@ -2032,7 +2194,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) fThreadP.y1 = ylocp; fThreadP.x2 = xloc; fThreadP.y2 = yloc; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_LINE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; @@ -2044,7 +2206,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) fThreadP.w = TMath::Abs(xloc - xlocp); fThreadP.h = TMath::Abs(yloc - ylocp); fThreadP.bFill = kFALSE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; @@ -2061,17 +2223,17 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) if (mode == 0) { while (1) { fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_GET_EVENT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_EVENT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); event = (GdkEvent *) fThreadP.pRet; if (event->type == GDK_ENTER_NOTIFY) { fThreadP.pParam = event; - PostThreadMessage(fIDThread, WIN32_GDK_EVENT_FREE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_EVENT_FREE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; } fThreadP.pParam = event; - PostThreadMessage(fIDThread, WIN32_GDK_EVENT_FREE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_EVENT_FREE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } } else { @@ -2084,7 +2246,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) xlocp = event->button.x; ylocp = event->button.y; fThreadP.pParam = cursor; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); cursor = 0; break; @@ -2117,7 +2279,7 @@ Int_t TGWin32::RequestLocator(Int_t mode, Int_t ctyp, Int_t & x, Int_t & y) break; } fThreadP.pParam = event; - PostThreadMessage(fIDThread, WIN32_GDK_EVENT_FREE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_EVENT_FREE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); if (mode == 1) { @@ -2159,14 +2321,14 @@ Int_t TGWin32::RequestString(int x, int y, char *text) // change the cursor shape if (cursor == NULL) { fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_QUESTION_ARROW, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_NEW, GDK_QUESTION_ARROW, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); cursor = (GdkCursor *) fThreadP.pRet; } if (cursor != 0) { fThreadP.Drawable = (GdkDrawable *) gCws->window; fThreadP.pParam = cursor; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_CURSOR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_CURSOR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } for (nt = len_text; nt > 0 && text[nt - 1] == ' '; nt--); @@ -2174,12 +2336,12 @@ Int_t TGWin32::RequestString(int x, int y, char *text) // XGetInputFocus(fDisplay, &focuswindow, &focusrevert); // XSetInputFocus(fDisplay, (GdkWindow *)gCws->window, focusrevert, CurrentTime); fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT_FOCUS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT_FOCUS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); focuswindow = (HWND)fThreadP.pRet; // SetFocus((HWND) GDK_DRAWABLE_XID((GdkWindow *) gCws->window)); fThreadP.Drawable = (GdkDrawable *) gCws->window; - PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT_FOCUS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT_FOCUS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); while (key < 0) { @@ -2194,13 +2356,13 @@ Int_t TGWin32::RequestString(int x, int y, char *text) fThreadP.y = y; sprintf(fThreadP.sParam,"%s",text); fThreadP.iParam = nt; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_TEXT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_TEXT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.pParam = gTextFont; fThreadP.iParam = nt; sprintf(fThreadP.sParam,"%s",text); - PostThreadMessage(fIDThread, WIN32_GDK_GET_TEXT_WIDTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_TEXT_WIDTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); dx = fThreadP.iRet; @@ -2211,13 +2373,13 @@ Int_t TGWin32::RequestString(int x, int y, char *text) fThreadP.y = y; sprintf(fThreadP.sParam," "); fThreadP.iParam = 1; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_TEXT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_TEXT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - + fThreadP.pParam = gTextFont; fThreadP.iParam = pt; sprintf(fThreadP.sParam,"%s",text); - PostThreadMessage(fIDThread, WIN32_GDK_GET_TEXT_WIDTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_TEXT_WIDTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ddx = fThreadP.iRet; @@ -2233,13 +2395,13 @@ Int_t TGWin32::RequestString(int x, int y, char *text) else sprintf(fThreadP.sParam," "); fThreadP.iParam = 1; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_TEXT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_TEXT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); // XWindowEvent(fDisplay, (GdkWindow *)gCws->window, gKeybdMask, &event); // gdk_window_set_events((GdkWindow *)gCws->window, (GdkEventMask)gKeybdMask); fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_GET_EVENT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_EVENT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); event = (GdkEvent *) fThreadP.pRet; if (event != NULL) { @@ -2247,12 +2409,12 @@ Int_t TGWin32::RequestString(int x, int y, char *text) case GDK_BUTTON_PRESS: case GDK_ENTER_NOTIFY: fThreadP.Drawable = (GdkDrawable *) gCws->window; - PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT_FOCUS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT_FOCUS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; case GDK_LEAVE_NOTIFY: fThreadP.Drawable = (GdkDrawable *) focuswindow; - PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT_FOCUS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT_FOCUS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; case GDK_KEY_PRESS: @@ -2371,7 +2533,7 @@ Int_t TGWin32::RequestString(int x, int y, char *text) break; default: - PostThreadMessage(fIDThread, WIN32_GDK_BEEP, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_BEEP, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; } @@ -2379,7 +2541,7 @@ Int_t TGWin32::RequestString(int x, int y, char *text) } } fThreadP.pParam = event; - PostThreadMessage(fIDThread, WIN32_GDK_EVENT_FREE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_EVENT_FREE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } } @@ -2387,7 +2549,7 @@ Int_t TGWin32::RequestString(int x, int y, char *text) if (cursor != 0) { fThreadP.pParam = cursor; - PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_CURSOR_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); cursor = 0; } @@ -2420,16 +2582,16 @@ void TGWin32::RescaleWindow(int wid, unsigned int w, unsigned int h) fThreadP.Drawable = (GdkDrawable *) gTws->window; fThreadP.w = w; fThreadP.h = h; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_RESIZE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_RESIZE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); if (gTws->buffer) { // don't free and recreate pixmap when new pixmap is smaller if (gTws->width < w || gTws->height < h) { fThreadP.Drawable = (GdkDrawable *) gTws->buffer; - PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); depth = fThreadP.iRet; @@ -2438,14 +2600,14 @@ void TGWin32::RescaleWindow(int wid, unsigned int w, unsigned int h) fThreadP.h = h; fThreadP.iParam = depth; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gTws->buffer = (GdkPixmap *) fThreadP.pRet; } for (i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; fThreadP.pParam = None; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } SetColor(gGCpxmp, 0); @@ -2456,7 +2618,7 @@ void TGWin32::RescaleWindow(int wid, unsigned int w, unsigned int h) fThreadP.w = w; fThreadP.h = h; fThreadP.bFill = kTRUE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); SetColor(gGCpxmp, 1); if (gTws->double_buffer) @@ -2496,9 +2658,9 @@ int TGWin32::ResizePixmap(int wid, unsigned int w, unsigned int h) // don't free and recreate pixmap when new pixmap is smaller if (gTws->width < wval || gTws->height < hval) { fThreadP.Drawable = (GdkDrawable *) gTws->window; - PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); depth = fThreadP.iRet; fThreadP.Drawable = NULL; @@ -2506,12 +2668,12 @@ int TGWin32::ResizePixmap(int wid, unsigned int w, unsigned int h) fThreadP.h = hval; fThreadP.iParam = depth; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gTws->window = (GdkPixmap *) fThreadP.pRet; } fThreadP.Drawable = (GdkDrawable *) gTws->window; - PostThreadMessage(fIDThread, WIN32_GDK_DRAWABLE_GET_SIZE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAWABLE_GET_SIZE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ww = fThreadP.w; hh = fThreadP.h; @@ -2519,7 +2681,7 @@ int TGWin32::ResizePixmap(int wid, unsigned int w, unsigned int h) for (i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; fThreadP.pParam = None; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } @@ -2531,7 +2693,7 @@ int TGWin32::ResizePixmap(int wid, unsigned int w, unsigned int h) fThreadP.w = ww; fThreadP.h = hh; fThreadP.bFill = kTRUE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); SetColor(gGCpxmp, 1); @@ -2554,13 +2716,13 @@ void TGWin32::ResizeWindow(int wid) int xval = 0, yval = 0; GdkWindow *win, *root = NULL; int wval = 0, hval = 0, border = 0, depth = 0; - + gTws = &fWindows[wid]; win = (GdkWindow *) gTws->window; fThreadP.Drawable = (GdkDrawable *) win; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_GEOMETRY, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_GEOMETRY, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); xval = fThreadP.x; yval = fThreadP.y; @@ -2576,15 +2738,15 @@ void TGWin32::ResizeWindow(int wid) fThreadP.Drawable = (GdkDrawable *) gTws->window; fThreadP.w = wval; fThreadP.h = hval; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_RESIZE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_RESIZE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); if (gTws->buffer) { if (gTws->width < wval || gTws->height < hval) { fThreadP.Drawable = (GdkDrawable *) gTws->buffer; - PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); depth = fThreadP.iRet; fThreadP.Drawable = NULL; @@ -2592,14 +2754,14 @@ void TGWin32::ResizeWindow(int wid) fThreadP.h = hval; fThreadP.iParam = depth; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gTws->buffer = (GdkPixmap *) fThreadP.pRet; } for (i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; fThreadP.pParam = None; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } SetColor(gGCpxmp, 0); @@ -2610,7 +2772,7 @@ void TGWin32::ResizeWindow(int wid) fThreadP.w = wval; fThreadP.h = hval; fThreadP.bFill = kTRUE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); SetColor(gGCpxmp, 1); if (gTws->double_buffer) @@ -2642,14 +2804,14 @@ void TGWin32::SelectWindow(int wid) fThreadP.region.height = gCws->hclip; for (i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_RECT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_RECT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } } else { for (i = 0; i < kMAXGC; i++) fThreadP.GC = (GdkGC *) gGClist[i]; fThreadP.pParam = None; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } LeaveCriticalSection(flpCriticalSection); @@ -2701,7 +2863,7 @@ void TGWin32::SetClipOFF(int wid) for (int i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; fThreadP.pParam = None; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } LeaveCriticalSection(flpCriticalSection); @@ -2730,7 +2892,7 @@ void TGWin32::SetClipRegion(int wid, int x, int y, unsigned int w, fThreadP.region.height = gTws->hclip; for (int i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_RECT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_RECT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } } @@ -2774,15 +2936,15 @@ void TGWin32::SetColor(GdkGC * gc, int ci) if (fDrawMode == kXor) { fThreadP.GC = (GdkGC *) gc; - PostThreadMessage(fIDThread, WIN32_GDK_GC_GET_VALUES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_GET_VALUES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - + fThreadP.GC = (GdkGC *) gc; fThreadP.color.pixel = gColors[ci].color.pixel ^ fThreadP.gcvals.background.pixel; fThreadP.color.red = GetRValue(fThreadP.color.pixel); fThreadP.color.green = GetGValue(fThreadP.color.pixel); fThreadP.color.blue = GetBValue(fThreadP.color.pixel); - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { fThreadP.GC = (GdkGC *) gc; @@ -2790,21 +2952,21 @@ void TGWin32::SetColor(GdkGC * gc, int ci) fThreadP.color.red = gColors[ci].color.red; fThreadP.color.green = gColors[ci].color.green; fThreadP.color.blue = gColors[ci].color.blue; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); // make sure that foreground and background are different fThreadP.GC = (GdkGC *) gc; - PostThreadMessage(fIDThread, WIN32_GDK_GC_GET_VALUES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_GET_VALUES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - + if (fThreadP.gcvals.foreground.pixel == fThreadP.gcvals.background.pixel) { fThreadP.GC = (GdkGC *) gc; fThreadP.color.pixel = gColors[!ci].color.pixel; fThreadP.color.red = gColors[!ci].color.red; fThreadP.color.green = gColors[!ci].color.green; fThreadP.color.blue = gColors[!ci].color.blue; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } } @@ -2820,7 +2982,7 @@ void TGWin32::SetCursor(int wid, ECursor cursor) gTws = &fWindows[wid]; fThreadP.Drawable = (GdkDrawable *) gTws->window; fThreadP.pParam = fCursors[cursor]; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_CURSOR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_SET_CURSOR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -2884,7 +3046,7 @@ void TGWin32::SetDoubleBufferON() return; EnterCriticalSection(flpCriticalSection); if (!gTws->buffer) { - PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); depth = fThreadP.iRet; fThreadP.Drawable = NULL; @@ -2892,7 +3054,7 @@ void TGWin32::SetDoubleBufferON() fThreadP.h = gTws->height; fThreadP.iParam = depth; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIXMAP_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gTws->buffer = (GdkPixmap *) fThreadP.pRet; SetColor(gGCpxmp, 0); @@ -2903,14 +3065,14 @@ void TGWin32::SetDoubleBufferON() fThreadP.w = gTws->width; fThreadP.h = gTws->height; fThreadP.bFill = kTRUE; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_RECTANGLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); SetColor(gGCpxmp, 1); } for (int i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; fThreadP.pParam = None; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_CLIP_MASK, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } gTws->double_buffer = 1; @@ -2936,7 +3098,7 @@ void TGWin32::SetDrawMode(EDrawMode mode) case kCopy: for (i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FUNCTION, GDK_COPY, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FUNCTION, GDK_COPY, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } break; @@ -2944,7 +3106,7 @@ void TGWin32::SetDrawMode(EDrawMode mode) case kXor: for (i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FUNCTION, GDK_XOR, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FUNCTION, GDK_XOR, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } break; @@ -2952,7 +3114,7 @@ void TGWin32::SetDrawMode(EDrawMode mode) case kInvert: for (i = 0; i < kMAXGC; i++) { fThreadP.GC = (GdkGC *) gGClist[i]; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FUNCTION, GDK_INVERT, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FUNCTION, GDK_INVERT, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } break; @@ -2976,7 +3138,7 @@ void TGWin32::SetFillColor(Color_t cindex) // invalidate fill pattern if (gFillPattern != NULL) { fThreadP.Drawable = (GdkDrawable *) gFillPattern; - PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gFillPattern = NULL; } @@ -3014,7 +3176,7 @@ void TGWin32::SetFillStyleIndex(Int_t style, Int_t fasi) case 1: // solid gFillHollow = 0; fThreadP.GC = (GdkGC *) gGCfill; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FILL, GDK_SOLID, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FILL, GDK_SOLID, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); break; @@ -3025,12 +3187,12 @@ void TGWin32::SetFillStyleIndex(Int_t style, Int_t fasi) case 3: // hatch gFillHollow = 0; fThreadP.GC = (GdkGC *) gGCfill; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FILL, GDK_STIPPLED, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FILL, GDK_STIPPLED, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); if (fasi != current_fasi) { if (gFillPattern != NULL) { fThreadP.Drawable = (GdkDrawable *) gFillPattern; - PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_PIX_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gFillPattern = NULL; } @@ -3118,13 +3280,13 @@ void TGWin32::SetFillStyleIndex(Int_t style, Int_t fasi) break; } fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_BMP_CREATE_FROM_DATA, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_BMP_CREATE_FROM_DATA, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gFillPattern = (GdkPixmap *) fThreadP.pRet; - + fThreadP.GC = (GdkGC *) gGCfill; fThreadP.pParam = gFillPattern; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_STIPPLE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_STIPPLE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); current_fasi = fasi; } @@ -3143,7 +3305,7 @@ void TGWin32::SetInput(int inp) EnterCriticalSection(flpCriticalSection); fThreadP.Drawable = gCws->window; - PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT, inp, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_SET_INPUT, inp, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -3182,7 +3344,7 @@ void TGWin32::SetLineType(int n, int *dash) fThreadP.iParam = gLineStyle; fThreadP.iParam1 = gCapStyle; fThreadP.iParam2 = gJoinStyle; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } else { int i, j; @@ -3200,10 +3362,10 @@ void TGWin32::SetLineType(int n, int *dash) fThreadP.iParam = gLineStyle; fThreadP.iParam1 = gCapStyle; fThreadP.iParam2 = gJoinStyle; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.GC = (GdkGC *) gGCdash; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } LeaveCriticalSection(flpCriticalSection); @@ -3255,10 +3417,10 @@ void TGWin32::SetLineWidth(Width_t width) fThreadP.iParam = gLineStyle; fThreadP.iParam1 = gCapStyle; fThreadP.iParam2 = gJoinStyle; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.GC = (GdkGC *) gGCdash; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_LINE_ATTR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -3584,7 +3746,7 @@ void TGWin32::SetOpacity(Int_t percent) EnterCriticalSection(flpCriticalSection); Int_t depth; - PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GET_DEPTH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); depth = fThreadP.iRet; if (depth <= 8) { @@ -3613,7 +3775,7 @@ void TGWin32::SetOpacity(Int_t percent) fThreadP.w = gCws->width; fThreadP.h = gCws->height; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_GET, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_GET, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); GdkImage *image = (GdkImage *)fThreadP.pRet; @@ -3627,7 +3789,7 @@ void TGWin32::SetOpacity(Int_t percent) } if (ncolors == 0) { fThreadP.pParam = image; - PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ::operator delete(orgcolors); LeaveCriticalSection(flpCriticalSection); @@ -3647,7 +3809,7 @@ void TGWin32::SetOpacity(Int_t percent) // put image back in pixmap on server fThreadP.Drawable = gCws->drawing; - fThreadP.GC = gGCpxmp; + fThreadP.GC = gGCpxmp; fThreadP.pParam = image; fThreadP.x = 0; fThreadP.y = 0; @@ -3655,10 +3817,10 @@ void TGWin32::SetOpacity(Int_t percent) fThreadP.y1 = 0; fThreadP.w = gCws->width; fThreadP.h = gCws->height; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_IMAGE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_IMAGE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); // clean up @@ -3666,12 +3828,12 @@ void TGWin32::SetOpacity(Int_t percent) fThreadP.pParam = fColormap; fThreadP.pParam2 = tmpc; fThreadP.iParam = ntmpc; - PostThreadMessage(fIDThread, WIN32_GDK_COLORS_FREE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLORS_FREE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); delete[]tmpc; } fThreadP.pParam = image; - PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ::operator delete(orgcolors); LeaveCriticalSection(flpCriticalSection); @@ -3728,16 +3890,16 @@ void TGWin32::MakeOpaqueColors(Int_t percent, ULong_t * orgcolors, fThreadP.pParam = fColormap; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); GdkColorContext *cc = (GdkColorContext *)fThreadP.pRet; fThreadP.pParam = cc; fThreadP.pRet = xcol; fThreadP.iParam = ncolors; - PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_QUERY_COLORS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_QUERY_COLORS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - + UShort_t add = percent * kBIGGEST_RGB_VALUE / 100; Int_t val; @@ -3754,10 +3916,10 @@ void TGWin32::MakeOpaqueColors(Int_t percent, ULong_t * orgcolors, if (val > kBIGGEST_RGB_VALUE) val = kBIGGEST_RGB_VALUE; xcol[i].blue = (UShort_t) val; - + fThreadP.pParam = fColormap; fThreadP.pRet = &xcol[i]; - PostThreadMessage(fIDThread, WIN32_GDK_COLOR_ALLOC, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_ALLOC, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); if (!fThreadP.iRet) @@ -3818,9 +3980,9 @@ void TGWin32::SetRGB(int cindex, float r, float g, float b) fThreadP.pParam = fColormap; fThreadP.iParam = 1; fThreadP.iParam1 = 1; - PostThreadMessage(fIDThread, WIN32_GDK_COLORMAP_ALLOC_COLOR, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLORMAP_ALLOC_COLOR, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - + if (fThreadP.iRet != 0) {//gdk_colormap_alloc_color(fColormap, &xcol, 1, 1) != 0) { gColors[cindex].defined = 1; gColors[cindex].color.pixel = fThreadP.color.pixel; @@ -3902,7 +4064,7 @@ void TGWin32::SetTextColor(Color_t cindex) SetColor(gGCtext, Int_t(cindex)); fThreadP.GC = (GdkGC *) gGCtext; - PostThreadMessage(fIDThread, WIN32_GDK_GC_GET_VALUES, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_GET_VALUES, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.GC = (GdkGC *) gGCinvt; @@ -3910,23 +4072,23 @@ void TGWin32::SetTextColor(Color_t cindex) fThreadP.color.red = fThreadP.gcvals.background.red; fThreadP.color.green = fThreadP.gcvals.background.green; fThreadP.color.blue = fThreadP.gcvals.background.blue; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FOREGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - + fThreadP.GC = (GdkGC *) gGCinvt; fThreadP.color.pixel = fThreadP.gcvals.foreground.pixel; fThreadP.color.red = fThreadP.gcvals.foreground.red; fThreadP.color.green = fThreadP.gcvals.foreground.green; fThreadP.color.blue = fThreadP.gcvals.foreground.blue; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); - + fThreadP.GC = (GdkGC *) gGCtext; fThreadP.color.pixel = gColors[0].color.pixel; fThreadP.color.red = gColors[0].color.red; fThreadP.color.green = gColors[0].color.green; fThreadP.color.blue = gColors[0].color.blue; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_BACKGROUND, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); } @@ -3961,11 +4123,11 @@ Int_t TGWin32::SetTextFont(char *fontname, ETextSetMode mode) gTextFont = gFont[i].id; fThreadP.GC = (GdkGC *) gGCtext; fThreadP.pParam = gTextFont; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FONT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FONT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.GC = (GdkGC *) gGCinvt; fThreadP.pParam = gTextFont; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FONT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FONT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); return 0; @@ -3975,7 +4137,7 @@ Int_t TGWin32::SetTextFont(char *fontname, ETextSetMode mode) sprintf(fThreadP.sParam,"%s",fname); fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fontlist = (char **)fThreadP.pRet; fontcount = fThreadP.iRet; @@ -3984,16 +4146,16 @@ Int_t TGWin32::SetTextFont(char *fontname, ETextSetMode mode) if (mode == kLoad) { sprintf(fThreadP.sParam,"%s",fontname); fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONT_LOAD, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gTextFont = (GdkFont *)fThreadP.pRet; fThreadP.GC = (GdkGC *) gGCtext; fThreadP.pParam = gTextFont; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FONT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FONT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); fThreadP.GC = (GdkGC *) gGCinvt; fThreadP.pParam = gTextFont; - PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FONT, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_GC_SET_FONT, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); gFont[gCurrentFontNumber].id = gTextFont; strcpy(gFont[gCurrentFontNumber].name, fname); @@ -4002,7 +4164,7 @@ Int_t TGWin32::SetTextFont(char *fontname, ETextSetMode mode) gCurrentFontNumber = 0; } fThreadP.pParam = fontlist; - PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_FREE, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FONTLIST_FREE, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); LeaveCriticalSection(flpCriticalSection); return 0; @@ -4129,12 +4291,12 @@ void TGWin32::UpdateWindow(int mode) fThreadP.xpos = 0; fThreadP.ypos = 0; - PostThreadMessage(fIDThread, WIN32_GDK_WIN_COPY_AREA, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WIN_COPY_AREA, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } if (mode == 1) { - PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_FLUSH, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } // else @@ -4154,7 +4316,7 @@ void TGWin32::Warp(int ix, int iy) fThreadP.Drawable = (GdkDrawable *) gCws->window; fThreadP.x = ix; fThreadP.y = iy; - PostThreadMessage(fIDThread, WIN32_GDK_WARP, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_WARP, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); // SetCursorPos(tmp.x,tmp.y); LeaveCriticalSection(flpCriticalSection); @@ -4258,13 +4420,13 @@ void TGWin32::ImgPickPalette(GdkImage * image, Int_t & ncol, Int_t * &R, fThreadP.pParam = fColormap; fThreadP.pParam1 = xcol; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_NEW, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_NEW, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); GdkColorContext *cc = (GdkColorContext *)fThreadP.pRet; fThreadP.pParam = cc; fThreadP.iParam = ncolors; - PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_QUERY_COLORS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_COLOR_CONTEXT_QUERY_COLORS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); // create RGB arrays and store RGB's for each color and set number of colors @@ -4307,7 +4469,7 @@ Int_t TGWin32::WriteGIF(char *name) if (ximage) { fThreadP.pParam = ximage; - PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_UNREF, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_UNREF, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ximage = 0; } @@ -4318,7 +4480,7 @@ Int_t TGWin32::WriteGIF(char *name) fThreadP.w = gCws->width; fThreadP.h = gCws->height; fThreadP.pRet = NULL; - PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_GET, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_IMAGE_GET, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); ximage = (GdkImage *)fThreadP.pRet; @@ -4408,7 +4570,7 @@ void TGWin32::PutImage(int offset, int itran, int x0, int y0, int nx, fThreadP.GC = (GdkGC *) gGCline; fThreadP.pParam = &lines[icol][0]; fThreadP.iParam = MAX_SEGMENT; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_SEGMENTS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_SEGMENTS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); nlines[icol] = 0; } @@ -4429,7 +4591,7 @@ void TGWin32::PutImage(int offset, int itran, int x0, int y0, int nx, fThreadP.GC = (GdkGC *) gGCline; fThreadP.pParam = &lines[icol][0]; fThreadP.iParam = MAX_SEGMENT; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_SEGMENTS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_SEGMENTS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); nlines[icol] = 0; } @@ -4443,7 +4605,7 @@ void TGWin32::PutImage(int offset, int itran, int x0, int y0, int nx, fThreadP.GC = (GdkGC *) gGCline; fThreadP.pParam = &lines[icol][0]; fThreadP.iParam = nlines[i]; - PostThreadMessage(fIDThread, WIN32_GDK_DRAW_SEGMENTS, 0, 0L); + PostThreadMessage(fIDThread, WIN32_GDK_DRAW_SEGMENTS, 0, 0L); WaitForSingleObject(fThreadP.hThrSem, INFINITE); } } diff --git a/winnt/src/TWinNTSystem.cxx b/winnt/src/TWinNTSystem.cxx index 90cd9d78b71..d9aa41cdee4 100644 --- a/winnt/src/TWinNTSystem.cxx +++ b/winnt/src/TWinNTSystem.cxx @@ -1,4 +1,4 @@ -// @(#)root/winnt:$Name: $:$Id: TWinNTSystem.cxx,v 1.38 2002/12/10 21:39:44 brun Exp $ +// @(#)root/winnt:$Name: $:$Id: TWinNTSystem.cxx,v 1.39 2003/01/19 11:35:38 brun Exp $ // Author: Fons Rademakers 15/09/95 /************************************************************************* @@ -878,6 +878,10 @@ int TWinNTSystem::MakeDirectory(const char *name) // Make a Unix file system directory. Returns 0 in case of success and // -1 if the directory could not be created. + TSystem *helper = FindHelper(name); + if (helper) + return helper->MakeDirectory(name); + #ifdef WATCOM //*-* It must be as follows if (!name) return 0; @@ -894,6 +898,12 @@ void TWinNTSystem::FreeDirectory(void *dirp) { // Close a WinNT file system directory. + TSystem *helper = FindHelper(0, dirp); + if (helper) { + helper->FreeDirectory(dirp); + return; + } + if (dirp) ::FindClose(dirp); } @@ -901,10 +911,13 @@ void TWinNTSystem::FreeDirectory(void *dirp) //______________________________________________________________________________ const char *TWinNTSystem::GetDirEntry(void *dirp) { -// Returns the next directory entry. + // Returns the next directory entry. - if (dirp) - { + TSystem *helper = FindHelper(0, dirp); + if (helper) + return helper->GetDirEntry(dirp); + + if (dirp) { HANDLE SearchFile = (HANDLE)dirp; if (FindNextFile(SearchFile,&fFindFileData)) return (const char *)(fFindFileData.cFileName); @@ -928,6 +941,10 @@ void *TWinNTSystem::OpenDirectory(const char *dir) { // Open a directory. Returns 0 if directory does not exist. + TSystem *helper = FindHelper(dir); + if (helper) + return helper->OpenDirectory(dir); + struct stat finfo; if (stat(dir, &finfo) < 0) @@ -1136,6 +1153,10 @@ Bool_t TWinNTSystem::AccessPathName(const char *path, EAccessMode mode) // Mode is the same as for the WinNT access(2) function. // Attention, bizarre convention of return value!! + TSystem *helper = FindHelper(path); + if (helper) + return helper->AccessPathName(path, mode); + if (::_access(path, mode) == 0) return kFALSE; fLastErrorString = sys_errlist[GetErrno()]; @@ -1190,6 +1211,10 @@ int TWinNTSystem::GetPathInfo(const char *path, Long_t *id, Long_t *size, // The function returns 0 in case of success and 1 if the file could // not be stat'ed. + TSystem *helper = FindHelper(path); + if (helper) + return helper->GetPathInfo(path, id, size, flags, modtime); + return WinNTFilestat(path, id, size, flags, modtime); } diff --git a/x11/src/TGX11.cxx b/x11/src/TGX11.cxx index b1e1d534df9..09242a82c4a 100644 --- a/x11/src/TGX11.cxx +++ b/x11/src/TGX11.cxx @@ -1,4 +1,4 @@ -// @(#)root/x11:$Name: $:$Id: TGX11.cxx,v 1.26 2002/12/02 18:50:12 rdm Exp $ +// @(#)root/x11:$Name: $:$Id: TGX11.cxx,v 1.27 2003/01/20 07:25:02 brun Exp $ // Author: Rene Brun, Olivier Couet, Fons Rademakers 28/11/94 /************************************************************************* @@ -1069,21 +1069,13 @@ void TGX11::GetTextExtent(unsigned int &w, unsigned int &h, char *mess) // ih : text height // mess : message - w = XTextWidth(gTextFont, mess, strlen(mess)); - h = gTextFont->ascent; - -#if 0 - int direction, ascent, descent; - XCharStruct overall; - XTextExtents(gTextFont, mess, strlen(mess), &direction, &ascent, &descent, - &overall); - UInt_t ww = overall.rbearing - overall.lbearing; - UInt_t hh = overall.ascent + overall.descent; - - if ((int)h != ascent) printf("GetTextExtent: h = %d, ascent = %d\n", (int)h, ascent); - printf("GetTextExtent: current values: w = %d, h = %d\n", (int)w, (int)h); - printf(" new values: w = %d, h = %d\n", (int)ww, (int)hh); -#endif + XPoint *CBox; + CBox = (XPoint *)malloc((unsigned)(5*sizeof(XPoint))); + XRotSetMagnification(fTextMagnitude); + CBox = XRotTextExtents(fDisplay, gTextFont, 0., 0, 0, mess, 0); + w = CBox[2].x; + h = -CBox[2].y; + free((char *)CBox); } //______________________________________________________________________________ diff --git a/x11ttf/Module.mk b/x11ttf/Module.mk index 4b8a1a77a23..9fdd94936b1 100644 --- a/x11ttf/Module.mk +++ b/x11ttf/Module.mk @@ -36,18 +36,17 @@ INCLUDEFILES += $(X11TTFDEP) include/%.h: $(X11TTFDIRI)/%.h cp $< $@ -$(X11TTFLIB): $(X11TTFO) $(X11TTFDO) $(MAINLIBS) $(X11TTFLIBDEP) +$(X11TTFLIB): $(X11TTFO) $(X11TTFDO) $(FREETYPELIB) $(MAINLIBS) $(X11TTFLIBDEP) @$(MAKELIB) $(PLATFORM) $(LD) "$(LDFLAGS)" \ "$(SOFLAGS)" libGX11TTF.$(SOEXT) $@ \ - "$(X11TTFO) $(X11TTFDO)" \ - "$(X11TTFLIBEXTRA) $(TTFLIBDIR) $(TTFLIB)" + "$(X11TTFO) $(X11TTFDO)" "$(FREETYPELIB) $(X11TTFLIBEXTRA)" $(X11TTFDS): $(X11TTFH) $(X11TTFL) $(ROOTCINTTMP) @echo "Generating dictionary $@..." $(ROOTCINTTMP) -f $@ -c $(X11TTFH) $(X11TTFL) -$(X11TTFDO): $(X11TTFDS) - $(CXX) $(NOOPT) $(CXXFLAGS) -I$(TTFINCDIR) -I. -o $@ -c $< +$(X11TTFDO): $(X11TTFDS) $(FREETYPELIB) + $(CXX) $(NOOPT) $(CXXFLAGS) -I. -I$(FREETYPEDIRI) -o $@ -c $< all-x11ttf: $(X11TTFLIB) @@ -62,5 +61,5 @@ distclean-x11ttf: clean-x11ttf distclean:: distclean-x11ttf ##### extra rules ###### -$(X11TTFO): %.o: %.cxx - $(CXX) $(OPT) $(CXXFLAGS) -I$(TTFINCDIR) -o $@ -c $< +$(X11TTFO): %.o: %.cxx $(FREETYPELIB) + $(CXX) $(OPT) $(CXXFLAGS) -I$(FREETYPEDIRI) -o $@ -c $< diff --git a/x11ttf/inc/TGX11TTF.h b/x11ttf/inc/TGX11TTF.h index c44e5fff544..6155783db8c 100644 --- a/x11ttf/inc/TGX11TTF.h +++ b/x11ttf/inc/TGX11TTF.h @@ -1,4 +1,5 @@ -// @(#)root/x11ttf:$Name: $:$Id: TGX11TTF.h,v 1.2 2001/02/17 11:42:23 rdm Exp $ +// @(#)root/x11ttf:$Name: $:$Id: TGX11TTF.h,v 1.3 2003/01/20 08:44:47 brun Exp $ +// Author: Olivier Couet 01/10/02 // Author: Fons Rademakers 21/11/98 /************************************************************************* @@ -29,96 +30,35 @@ #include "TGX11.h" #endif -#if !defined(__CINT__) - -#if defined(R__HPUX) && !defined(R__ACC) -#define signed -#endif - -#include <freetype.h> - -#if defined(R__HPUX) && !defined(R__ACC) -#undef signed +#ifndef ROOT_TTF +#include "TTF.h" #endif -#else - -struct TT_Face_Properties; -struct TT_Face; -struct TT_Glyph; -struct TT_Instance; -struct TT_CharMap; -struct TT_Engine; -struct TT_Matrix; - -#endif - -class TList; -class THashTable; -class TTChar; - class TGX11TTF : public TGX11 { private: - enum { kTTMaxFonts = 32, kCacheSize = 3000, kHashSize = 255 }; enum EAlign { kNone, kTLeft, kTCenter, kTRight, kMLeft, kMCenter, kMRight, kBLeft, kBCenter, kBRight }; - Int_t fFontCount; // number of fonts loaded - Int_t fCurFontIdx; // current font index - char *fFontName[kTTMaxFonts]; // font name - TT_Face_Properties *fProperties[kTTMaxFonts]; // font properties - TT_Face *fFace[kTTMaxFonts]; // font face - TT_Glyph *fGlyph[kTTMaxFonts]; // font glyph - TT_Instance *fInstance[kTTMaxFonts]; // font instance - TT_CharMap *fCharMap[kTTMaxFonts]; // font character map - TT_Engine *fEngine; // TrueType font renderer - TT_Matrix *fRotMatrix; // rotation matrix - Int_t fCacheCount; // number of chars in cache - Int_t fCacheHits; // number of cache hits - Int_t fCacheMisses; // number of cache misses - THashTable *fCharCache; // character cache - TList *fLRU; // Least Recent Used chars - Bool_t fHinting; // use hinting (true by default) - Bool_t fSmoothing; // use anti-aliasing (true when >8 planes, false otherwise) + FT_Vector fAlign; // alignment vector - TTChar *GetChar(UInt_t code, UInt_t size, Float_t angle, Bool_t force = kTRUE); - TTChar *LookupChar(UInt_t code, UInt_t size, Float_t angle, const char *fontname); - TTChar *AllocChar(UInt_t code, UInt_t size, const char *fontname); - TTChar *AllocRotatedChar(UInt_t code, UInt_t size, Float_t angle, const char *fontname); - Short_t CharToUnicode(UInt_t code); - Int_t LoadTrueTypeChar(Int_t idx); - XImage *GetBackground(Int_t x, Int_t y, UInt_t w, UInt_t h); - void DrawRotatedText(Int_t x, Int_t y, Float_t angle, const char *text, ETextMode mode); - void DrawImage(TTChar *c, ULong_t fore, ULong_t back, XImage *xim, Int_t bx, Int_t by); - void GetTextExtent(UInt_t &w, UInt_t &h, Int_t &maxAscent, const char *text); - void GetRotatedTextExtent(UInt_t &w, UInt_t &h, Int_t &xoff, Int_t &yoff, Float_t angle, const char *text); - void Align(UInt_t w, UInt_t h, Int_t maxAscent, Int_t &x, Int_t &y); - void AlignRotated(UInt_t w, UInt_t h, Int_t xoff, Int_t yoff, Int_t &x, Int_t &y); + void Align(void); + void DrawImage(FT_Bitmap *source, ULong_t fore, ULong_t back, XImage *xim, + Int_t bx, Int_t by); Bool_t IsVisible(Int_t x, Int_t y, UInt_t w, UInt_t h); - void ClearCache(); - void SetRotationMatrix(Float_t angle); + XImage *GetBackground(Int_t x, Int_t y, UInt_t w, UInt_t h); + void RenderString(Int_t x, Int_t y, ETextMode mode); public: - TGX11TTF(); TGX11TTF(const TGX11 &org); virtual ~TGX11TTF(); - void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode); - void GetTextExtent(UInt_t &w, UInt_t &h, char *text); - Int_t SetTextFont(char *fontname, ETextSetMode mode); - void SetTextFont(Font_t fontnumber); - void SetTextSize(Float_t textsize); - - Int_t GetCacheCount() const { return fCacheCount; } - Int_t GetCacheHits() const { return fCacheHits; } - Int_t GetCacheMisses() const { return fCacheMisses; } - - Bool_t GetHinting() const { return fHinting; } - Bool_t GetSmoothing() const { return fSmoothing; } - void SetHinting(Bool_t state); - void SetSmoothing(Bool_t state); + void DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, + const char *text, ETextMode mode); + void SetTextFont(Font_t fontnumber); + Int_t SetTextFont(char *fontname, ETextSetMode mode); + void SetTextSize(Float_t textsize); ClassDef(TGX11TTF,0) //Interface to X11 + TTF font handling }; diff --git a/x11ttf/src/TGX11TTF.cxx b/x11ttf/src/TGX11TTF.cxx index 2a3d82fe55c..46cd51007d5 100644 --- a/x11ttf/src/TGX11TTF.cxx +++ b/x11ttf/src/TGX11TTF.cxx @@ -1,4 +1,5 @@ -// @(#)root/x11ttf:$Name: $:$Id: TGX11TTF.cxx,v 1.7 2002/08/23 14:49:23 rdm Exp $ +// @(#)root/x11ttf:$Name: $:$Id: TGX11TTF.cxx,v 1.8 2003/01/20 08:44:47 brun Exp $ +// Author: Olivier Couet 01/10/02 // Author: Fons Rademakers 21/11/98 /************************************************************************* @@ -21,24 +22,9 @@ // // ////////////////////////////////////////////////////////////////////////// -#ifdef HAVE_CONFIG -#include "config.h" -#endif +#include <stdlib.h> #include "TGX11TTF.h" -#include "TSystem.h" -#include "TEnv.h" -#include "TList.h" -#include "THashTable.h" -#include "TMath.h" - - -ClassImp(TGX11TTF) - - -// to scale TT fonts to same size as X11 fonts -const Float_t kScale = 0.7; - ////////////////////////////////////////////////////////////////////////// @@ -51,12 +37,12 @@ const Float_t kScale = 0.7; // // ////////////////////////////////////////////////////////////////////////// -class TTFInit { +class TTFX11Init { public: - TTFInit(); + TTFX11Init(); }; -TTFInit::TTFInit() +TTFX11Init::TTFX11Init() { if (gVirtualX->IsA() == TGX11::Class()) { TGX11 *oldg = (TGX11 *) gVirtualX; @@ -65,73 +51,10 @@ TTFInit::TTFInit() } } -static TTFInit gTTFInit; - - -// Class (actually structure) containing character description - -class TTChar : public TObject { - -public: - UInt_t fSize; // char size (= nint(fTextSize*kScale)) - UInt_t fWidth; // bitmap width - UInt_t fBwidth; // bitmap width, byte boundary - UInt_t fHeight; // bitmap height - UInt_t fCode; // actual char code - UInt_t fCharlen; // origin x axis advance width - Float_t fAngle; // rotation angle in degrees - Int_t fAscent; // (top of bitmap) - (origin y axis) - Int_t fDescent; // (origin y axis) - (bottom of bitmap) - Int_t fXoff; // (left of bitmap) - (origin x axis) - const char *fFontName; // font name (pointer to, not a copy) - UChar_t *fBitmap; // bitmap representing character - TObjLink *fLink; // keep track where in LRU list we are stored - - TTChar(); - ~TTChar(); - Bool_t IsEqual(const TObject *obj) const ; - ULong_t Hash() const; -}; - -TTChar::TTChar() -{ - fFontName = 0; - fBitmap = 0; -} - -TTChar::~TTChar() -{ - delete [] fBitmap; -} - -Bool_t TTChar::IsEqual(const TObject *obj) const -{ - TTChar *c = (TTChar *) obj; - if (fCode == c->fCode && fSize == c->fSize && fAngle == c->fAngle && - !strcmp(fFontName, c->fFontName)) return kTRUE; - return kFALSE; -} - -ULong_t TTChar::Hash() const -{ - return fCode ^ fSize; -} - - -inline Long_t TTFloor(Long_t x) { return x & -64; } -inline Long_t TTCeil(Long_t x) { return (x + 63) & -64; } +static TTFX11Init gTTFX11Init; +ClassImp(TGX11TTF) -//______________________________________________________________________________ -TGX11TTF::TGX11TTF() -{ - fFontCount = 0; - fCharCache = 0; - fLRU = 0; - fRotMatrix = 0; - fEngine = 0; -} - //______________________________________________________________________________ TGX11TTF::TGX11TTF(const TGX11 &org) : TGX11(org) { @@ -140,289 +63,258 @@ TGX11TTF::TGX11TTF(const TGX11 &org) : TGX11(org) SetName("X11TTF"); SetTitle("ROOT interface to X11 with TrueType fonts"); - fFontCount = 0; - fCurFontIdx = -1; - fCacheCount = 0; - fCacheHits = 0; - fCacheMisses = 0; - fRotMatrix = 0; - - fHinting = kTRUE; - fSmoothing = kFALSE; - if (fDepth > 8) - fSmoothing = kTRUE; + if (!TTF::fgInit) TTF::Init(); - TT_Error error; - - // Initialize TTF engine - fEngine = new TT_Engine; - if ((error = TT_Init_FreeType(fEngine))) { - Error("TGX11TTF", "error initializing engine, code = %d", (int)error); - return; + if (fDepth > 8) { + TTF::SetSmoothing(kTRUE); + } else { + TTF::SetSmoothing(kFALSE); } fHasTTFonts = kTRUE; - - // load default font (arialbd), if this fails we'll continue - // using X11 fonts (SetTextFont will turn off fHasTTFonts) - SetTextFont(62); - - fCharCache = new THashTable(kHashSize); - fLRU = new TList; } //______________________________________________________________________________ TGX11TTF::~TGX11TTF() { - // Cleanup. - - for (int i = 0; i < fFontCount; i++) { - delete fCharMap[i]; - delete fProperties[i]; - TT_Close_Face(*fFace[i]); - delete fFace[i]; - delete fGlyph[i]; - delete fInstance[i]; - delete [] fFontName[i]; - } - - delete fRotMatrix; - - if (!fEngine) return; - TT_Done_FreeType(*fEngine); - delete fEngine; - - if (!fCharCache) return; - ClearCache(); - delete fCharCache; - delete fLRU; } //______________________________________________________________________________ -void TGX11TTF::ClearCache() +void TGX11TTF::Align(void) { - // Clear TTChar cache. + // Compute alignment variables. The alignment is done on the horizontal string + // then the rotation is applied on the alignment variables. + // SetRotation and LayoutGlyphs should have been called before. + + EAlign align = (EAlign) fTextAlign; + + // vertical alignment + if (align == kTLeft || align == kTCenter || align == kTRight) { + fAlign.y = TTF::fgAscent; + } else if (align == kMLeft || align == kMCenter || align == kMRight) { + fAlign.y = TTF::fgAscent/2; + } else { + fAlign.y = 0; + } - fLRU->Clear(); // must be before the cache delete, or use option "nodelete" - fCharCache->Delete(); + // horizontal alignment + if (align == kTRight || align == kMRight || align == kBRight) { + fAlign.x = TTF::fgWidth; + } else if (align == kTCenter || align == kMCenter || align == kBCenter) { + fAlign.x = TTF::fgWidth/2; + } else { + fAlign.x = 0; + } - fCacheCount = 0; - fCacheHits = 0; - fCacheMisses = 0; + FT_Vector_Transform(&fAlign, TTF::fgRotMatrix); + fAlign.x = fAlign.x >> 6; + fAlign.y = fAlign.y >> 6; } //______________________________________________________________________________ -void TGX11TTF::Align(UInt_t w, UInt_t, Int_t ascent, Int_t &x, Int_t &y) +void TGX11TTF::DrawImage(FT_Bitmap *source, ULong_t fore, ULong_t back, + XImage *xim, Int_t bx, Int_t by) { - // Change x,y position depending on required alignment. + // Draw FT_Bitmap bitmap to xim image at position bx,by using specified + // foreground color. - EAlign align = (EAlign) fTextAlign; - Int_t nl = 1; // number of lines + UChar_t d = 0, *s = source->buffer; - if (align == kTLeft || align == kTCenter || align == kTRight) - y += ascent; - else if (align == kMLeft || align == kMCenter || align == kMRight) - y = y - nl*ascent/2 + ascent; - else if (align == kBLeft || align == kBCenter || align == kBRight) - y = y - nl*ascent + ascent; - else // kNone - y = y; + if (TTF::fgSmoothing) { - if (align == kTLeft || align == kMLeft || align == kBLeft || align == kNone) - x = x; - else if (align == kTCenter || align == kMCenter || align == kBCenter) - x -= (Int_t) w / 2; - else - x -= w; -} + static XColor col[5]; + XColor *bcol = 0, *bc; + Int_t x, y; -//______________________________________________________________________________ -void TGX11TTF::AlignRotated(UInt_t w, UInt_t, Int_t, Int_t yoff, - Int_t &x, Int_t &y) -{ - // Change x,y position or rotated text depending on required alignment. + // background kClear, i.e. transparent, we take as background color + // the average of the rgb values of all pixels covered by this character + if (back == (ULong_t) -1 && (UInt_t)source->width) { + ULong_t r, g, b; + Int_t dots, dotcnt; + const Int_t maxdots = 50000; - EAlign align = (EAlign) fTextAlign; - Int_t nl = 1; // number of lines + dots = Int_t(source->width * source->rows); + dots = dots > maxdots ? maxdots : dots; + bcol = new XColor[dots]; + if (!bcol) return; + bc = bcol; + dotcnt = 0; + for (y = 0; y < (int) source->rows; y++) { + for (x = 0; x < (int) source->width; x++, bc++) { +/// bc->pixel = XGetPixel(xim, bx + x, by - c->TTF::fgAscent + y); + bc->pixel = XGetPixel(xim, bx + x, by + y); + bc->flags = DoRed | DoGreen | DoBlue; + if (++dotcnt >= maxdots) break; + } + } + QueryColors(fColormap, bcol, dots); + r = g = b = 0; + bc = bcol; + dotcnt = 0; + for (y = 0; y < (int) source->rows; y++) { + for (x = 0; x < (int) source->width; x++, bc++) { + r += bc->red; + g += bc->green; + b += bc->blue; + if (++dotcnt >= maxdots) break; + } + } + if (dots != 0) { + r /= dots; + g /= dots; + b /= dots; + } + bc = &col[0]; + if (bc->red == r && bc->green == g && bc->blue == b) + bc->pixel = back; + else { + bc->pixel = ~back; + bc->red = (UShort_t) r; + bc->green = (UShort_t) g; + bc->blue = (UShort_t) b; + } + } + delete [] bcol; + + // if fore or background have changed from previous character + // recalculate the 3 smooting colors (interpolation between fore- + // and background colors) + if (fore != col[4].pixel || back != col[0].pixel) { + col[4].pixel = fore; + col[4].flags = DoRed|DoGreen|DoBlue; + if (back != (ULong_t) -1) { + col[3].pixel = back; + col[3].flags = DoRed | DoGreen | DoBlue; + QueryColors(fColormap, &col[3], 2); + col[0] = col[3]; + } else { + QueryColors(fColormap, &col[4], 1); + } - if (align == kTLeft || align == kTCenter || align == kTRight) - y += yoff; - else if (align == kMLeft || align == kMCenter || align == kMRight) - y = y - nl*yoff/2 + yoff; - else if (align == kBLeft || align == kBCenter || align == kBRight) - y = y - nl*yoff + yoff; - else // kNone - y = y; + // interpolate between fore and backgound colors + for (x = 3; x > 0; x--) { + col[x].red = (col[4].red *x + col[0].red *(4-x)) /4; + col[x].green = (col[4].green*x + col[0].green*(4-x)) /4; + col[x].blue = (col[4].blue *x + col[0].blue *(4-x)) /4; + if (!AllocColor(fColormap, &col[x])) { + Warning("DrawImage", "cannot allocate smoothing color"); + col[x].pixel = col[x+1].pixel; + } + } + } - if (align == kTLeft || align == kMLeft || align == kBLeft || align == kNone) - x = x; - else if (align == kTCenter || align == kMCenter || align == kBCenter) - x -= (Int_t) w / 2; - else - x -= w; + // put smoothed character, character pixmap values are an index + // into the 5 colors used for aliasing (4 = foreground, 0 = background) + for (y = 0; y < (int) source->rows; y++) { + for (x = 0; x < (int) source->width; x++) { + d = *s++ & 0xff; + d = ((d + 10) * 5) / 256; + if (d > 4) d = 4; + if (d && x < (int) source->width) { + ULong_t p = col[d].pixel; + XPutPixel(xim, bx + x, by + y, p); + } + } + } + } else { + // no smoothing, just put character using foreground color + UChar_t* row=s; + for (int y = 0; y < (int) source->rows; y++) { + int n = 0; + s = row; + for (int x = 0; x < (int) source->width; x++) { + if (n == 0) d = *s++; + if (TESTBIT(d,7-n)) + XPutPixel(xim, bx + x, by + y, fore); + if (++n == (int) kBitsPerByte) n = 0; + } + row += source->pitch; + } + } } //______________________________________________________________________________ void TGX11TTF::DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn, const char *text, ETextMode mode) { - // Draw text using TrueType fonts. - + // Draw text using TrueType fonts. If TrueType fonts are not available the + // text is drawn with TGX11::DrawText. - -#ifndef R__TTFROT - if (!fHasTTFonts || angle != 0.) { -#else if (!fHasTTFonts) { -#endif - TGX11::DrawText(x, y, angle, mgn, text, mode); - return; - } - - - if (!text || !*text) return; - - // angles are between 0<=angle<360 degrees - while (angle < 0.) - angle += 360.; - - while (angle >= 360.) - angle -= 360.; - - // FreeType rotates clockwise - if (angle > 0) - angle = 360 - angle; - - angle = (Float_t)TMath::Nint(angle); // steps of 1 degree - - if (angle != 0.) { - DrawRotatedText(x, y, angle, text, mode); - return; - } - - if (gDebug > 0) - printf("TGX11TTF::DrawText: (x=%d,y=%d,ang=%f,mgn=%f,size=%f,mode=%s) %s\n", - x, y, angle, mgn, fTextSize, mode==0 ? "kClear" : "kOpaque", text); - - // get size of string so we can create an XImage for it - UInt_t w, h; - Int_t maxa; // maximum ascent - - GetTextExtent(w, h, maxa, text); - - if (w == 0) { - if (gDebug > 0) - Error("DrawText", "text width is 0, something went very wrong"); - return; + } else { + if (!TTF::fgInit) TTF::Init(); + TTF::SetRotationMatrix(angle); + TTF::PrepareString(text); + TTF::LayoutGlyphs(); + Align(); + RenderString(x, y, mode); } +} - Align(w, h, maxa, x, y); - - Int_t y1 = y - maxa; // top of image (while y is the text baseline) - - if (!IsVisible(x, y1, w, h)) return; - - // create image that will contain the text - UInt_t depth = fDepth; - XImage *xim = XCreateImage(fDisplay, fVisual, - depth, ZPixmap, 0, 0, w, h, - depth == 24 ? 32 : (depth==15?16:depth), 0); - - // use malloc since Xlib will use free() in XDestroyImage - xim->data = (char *) malloc(xim->bytes_per_line * h); - memset(xim->data, 0, xim->bytes_per_line * h); - - ULong_t bg; - XGCValues values; - XGetGCValues(fDisplay, *GetGC(3), GCForeground | GCBackground, &values); - - if (mode == kClear) { - // if mode == kClear we need to get an image of the background - XImage *bim = GetBackground(x, y1, w, h); - if (!bim) { - Error("DrawText", "error getting background image"); - return; - } +//______________________________________________________________________________ +XImage *TGX11TTF::GetBackground(Int_t x, Int_t y, UInt_t w, UInt_t h) +{ + // Get the background of the current window in an XImage. - // and copy it into the text image - Int_t xoff = 0, yoff = 0; - if (x < 0) xoff = -x; - if (y1 < 0) yoff = -y1; + XWindow_t *cws = GetCurrentWindow(); - for (int yp = 0; yp < (int) bim->height; yp++) { - for (int xp = 0; xp < (int) bim->width; xp++) { - ULong_t pixel = XGetPixel(bim, xp, yp); - XPutPixel(xim, xoff+xp, yoff+yp, pixel); - } - } - XDestroyImage(bim); - bg = (ULong_t) -1; - } else { - // if mode == kOpaque its simple, we just draw the background - XAddPixel(xim, values.background); - bg = values.background; + if (x < 0) { + w += x; + x = 0; } - - // loop over all characters and draw them in the xim image - Int_t bx = 0; - const char *s = text; - while (s && *s) { - UInt_t code = (UChar_t) *s++; - TTChar *c = GetChar(code, TMath::Nint(fTextSize * kScale), 0.); - if (!c) continue; - DrawImage(c, values.foreground, bg, xim, bx, maxa); - bx += c->fCharlen; + if (y < 0) { + h += y; + y = 0; } - // put image back to pixmap on X server - XWindow_t *cws = GetCurrentWindow(); - GC *gc = GetGC(6); // gGCpxmp - XPutImage(fDisplay, cws->drawing, *gc, xim, 0, 0, x, y1, w, h); + if (x+w > cws->width) w = cws->width - x; + if (y+h > cws->height) h = cws->height - y; - // cleanup - XDestroyImage(xim); + return XGetImage(fDisplay, cws->drawing, x, y, w, h, AllPlanes, ZPixmap); } //______________________________________________________________________________ -void TGX11TTF::DrawRotatedText(Int_t x, Int_t y, Float_t angle, const char *text, - ETextMode mode) +Bool_t TGX11TTF::IsVisible(Int_t x, Int_t y, UInt_t w, UInt_t h) { - // Draw rotated text using TrueType fonts. - - if (gDebug > 0) - printf("TGX11TTF::DrawRotatedText: (x=%d,y=%d,ang=%f,size=%f,mode=%s) %s\n", - x, y, angle, fTextSize, mode==0 ? "kClear" : "kOpaque", text); + // Test if there is really something to render - SetRotationMatrix(angle); + XWindow_t *cws = GetCurrentWindow(); - // get size of string so we can create an XImage for it - UInt_t w, h; - Int_t xoff, yoff; // offsets from desired x and y position + // If w or h is 0, very likely the string is only blank characters + if ((int)w == 0 || (int)h == 0) return kFALSE; - GetRotatedTextExtent(w, h, xoff, yoff, angle, text); + // If string falls outside window, there is probably no need to draw it. + if (x + (int)w <= 0 || x >= (int)cws->width) return kFALSE; + if (y + (int)h <= 0 || y >= (int)cws->height) return kFALSE; - printf("GetRotatedTextExtent: angle = %f, width = %d, height = %d, xoff = %d, yoff = %d\n", - angle,w,h,xoff,yoff); + return kTRUE; +} - if (w == 0) { - if (gDebug > 0) - Error("DrawText", "text width is 0, something went very wrong"); - return; - } +//______________________________________________________________________________ +void TGX11TTF::RenderString(Int_t x, Int_t y, ETextMode mode) +{ + // Perform the string rendering in the pad. + // LayoutGlyphs should have been called before. - AlignRotated(w, h, xoff, yoff, x, y); + TTGlyph* glyph = TTF::fgGlyphs; - Int_t y1 = y - yoff; // top of image (while y is the text baseline) - Int_t x1 = x + xoff; + // compute the size and position of the XImage that will contain the text + Int_t Xoff = 0; if (TTF::fgCBox.xMin < 0) Xoff = -TTF::fgCBox.xMin; + Int_t Yoff = 0; if (TTF::fgCBox.yMin < 0) Yoff = -TTF::fgCBox.yMin; + Int_t w = TTF::fgCBox.xMax + Xoff; + Int_t h = TTF::fgCBox.yMax + Yoff; + Int_t x1 = x-Xoff-fAlign.x; + Int_t y1 = y+Yoff+fAlign.y-h; if (!IsVisible(x1, y1, w, h)) return; - // create image that will contain the text + // create the XImage that will contain the text UInt_t depth = fDepth; - XImage *xim = XCreateImage(fDisplay, fVisual, - depth, ZPixmap, 0, 0, w, h, - depth == 24 ? 32 : (depth==15?16:depth), 0); + XImage *xim = 0; + xim = XCreateImage(fDisplay, fVisual, + depth, ZPixmap, 0, 0, w, h, + depth == 24 ? 32 : (depth==15?16:depth), 0); // use malloc since Xlib will use free() in XDestroyImage xim->data = (char *) malloc(xim->bytes_per_line * h); @@ -432,6 +324,7 @@ void TGX11TTF::DrawRotatedText(Int_t x, Int_t y, Float_t angle, const char *text XGCValues values; XGetGCValues(fDisplay, *GetGC(3), GCForeground | GCBackground, &values); + // get the background if (mode == kClear) { // if mode == kClear we need to get an image of the background XImage *bim = GetBackground(x1, y1, w, h); @@ -441,14 +334,14 @@ void TGX11TTF::DrawRotatedText(Int_t x, Int_t y, Float_t angle, const char *text } // and copy it into the text image - Int_t xoff1 = 0, yoff1 = 0; - if (x1 < 0) xoff1 = -x1; - if (y1 < 0) yoff1 = -y1; + Int_t xo = 0, yo = 0; + if (x1 < 0) xo = -x1; + if (y1 < 0) yo = -y1; for (int yp = 0; yp < (int) bim->height; yp++) { for (int xp = 0; xp < (int) bim->width; xp++) { ULong_t pixel = XGetPixel(bim, xp, yp); - XPutPixel(xim, xoff1+xp, yoff1+yp, pixel); + XPutPixel(xim, xo+xp, yo+yp, pixel); } } XDestroyImage(bim); @@ -459,132 +352,40 @@ void TGX11TTF::DrawRotatedText(Int_t x, Int_t y, Float_t angle, const char *text bg = values.background; } - // loop over all characters and draw them in the xim image - Int_t bx = 0, by = 0; - if (angle > 180.) by = h; - const char *s = text; - while (s && *s) { - UInt_t code = (UChar_t) *s++; - TTChar *c = GetChar(code, TMath::Nint(fTextSize * kScale), angle); - if (!c) continue; - //DrawImage(c, values.foreground, bg, xim, bx, by+c->fAscent); - DrawImage(c, values.foreground, bg, xim, bx, by); + // paint the glyphs in the XImage + glyph = TTF::fgGlyphs; + for (int n = 0; n < TTF::fgNumGlyphs; n++, glyph++) { + if (FT_Glyph_To_Bitmap(&glyph->fImage, + TTF::fgSmoothing ? ft_render_mode_normal + : ft_render_mode_mono, + 0, 1 )) continue; + FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph->fImage; + FT_Bitmap* source = &bitmap->bitmap; + Int_t bx, by; - TT_Pos vec_x, vec_y; - vec_x = c->fCharlen << 6; - vec_y = 0; - TT_Transform_Vector(&vec_x, &vec_y, fRotMatrix); - bx += Int_t(vec_x >> 6); - if (angle > 180.) - by -= Int_t(vec_y >> 6); - else - by += Int_t(vec_y >> 6); + bx = bitmap->left+Xoff; + by = h - bitmap->top-Yoff; + DrawImage(source, values.foreground, bg, xim, bx, by); } - // put image back to pixmap on X server + // put the Ximage on the screen XWindow_t *cws = GetCurrentWindow(); GC *gc = GetGC(6); // gGCpxmp XPutImage(fDisplay, cws->drawing, *gc, xim, 0, 0, x1, y1, w, h); - - // cleanup XDestroyImage(xim); } //______________________________________________________________________________ -void TGX11TTF::GetTextExtent(UInt_t &w, UInt_t &h, Int_t &maxAscent, const char *text) -{ - // Get bounding box of text, returns also the maximum ascent - // in the string. This is used to position the string (at y-maxAscent). - // Private interface. - - w = h = 0; - maxAscent = 0; - - const char *s = text; - int maxa = 0, maxd = 0, extra = 0; - - // loop over all characters in the string and calculate length + height - while (s && *s) { - UInt_t code = (UChar_t) *s++; - TTChar *c = GetChar(code, TMath::Nint(fTextSize * kScale), 0.); - if (!c) continue; - w += c->fCharlen; - extra = c->fXoff + c->fWidth - c->fCharlen; - maxa = TMath::Max(maxa, c->fAscent); - maxd = TMath::Max(maxd, c->fDescent); - - if (gDebug > 1) - printf("char %c: a = %d, d = %d, w = %d\n", code, c->fAscent, c->fDescent, c->fCharlen); - } - - if (extra > 0) w += extra; - h = maxa + maxd; - maxAscent = maxa; - - if (gDebug > 0) - printf("TGX11TTF::GetTextExtent: %d, %d, %d, %s\n", w, h, maxa, text); -} - -//______________________________________________________________________________ -void TGX11TTF::GetRotatedTextExtent(UInt_t &w, UInt_t &h, Int_t &xoff, Int_t &yoff, - Float_t angle, const char *text) -{ - // Get bounding box of rotated text, returns also the maximum descent - // in the string. This is used to position the string. Private interface. - - w = h = 0; - xoff = yoff = 0; - - const char *s = text; - int x = 0, y = 0, maxx = 0, maxy = 0, minx = 9999, miny = 9999; - - // loop over all characters in the string and calculate length + height - while (s && *s) { - UInt_t code = (UChar_t) *s++; - TTChar *c = GetChar(code, TMath::Nint(fTextSize * kScale), angle); - if (!c) continue; - - minx = TMath::Min(minx, x+c->fXoff); - miny = TMath::Min(miny, y+c->fDescent); - maxx = TMath::Max(maxx, int(x+c->fXoff+c->fWidth)); - maxy = TMath::Max(maxy, int(y+c->fDescent+c->fHeight)); - - TT_Pos vec_x, vec_y; - vec_x = c->fCharlen << 6; - vec_y = 0; - TT_Transform_Vector(&vec_x, &vec_y, fRotMatrix); - x += Int_t(vec_x >> 6); - y += Int_t(vec_y >> 6); - - if (gDebug > 1) - printf("char %c: a = %d, d = %d, w = %d\n", code, c->fAscent, c->fDescent, c->fCharlen); - } - - w = maxx - minx; - h = maxy - miny; - xoff = TMath::Min(minx, maxx); - yoff = TMath::Max(miny, maxy); - - if (gDebug > 0) - printf("TGX11TTF::GetRotatedTextExtent: %d, %d, %d, %d, %s\n", w, h, xoff, yoff, text); -} - -//______________________________________________________________________________ -void TGX11TTF::GetTextExtent(UInt_t &w, UInt_t &h, char *text) +void TGX11TTF::SetTextFont(Font_t fontnumber) { - // Get bounding box of text. + // Set specified font. -#ifndef R__TTFROT - if (!fHasTTFonts || fTextAngle != 0.) { -#else + fTextFont = fontnumber; if (!fHasTTFonts) { -#endif - TGX11::GetTextExtent(w, h, text); - return; + TGX11::SetTextFont(fontnumber); + } else { + TTF::SetTextFont(fontnumber); } - - Int_t maxa; - GetTextExtent(w, h, maxa, text); } //______________________________________________________________________________ @@ -599,773 +400,25 @@ Int_t TGX11TTF::SetTextFont(char *fontname, ETextSetMode mode) // Set text font to specified name. This function returns 0 if // the specified font is found, 1 if not. -#ifndef R__TTFROT - if (!fHasTTFonts || fTextAngle != 0.) -#else - if (!fHasTTFonts) -#endif + if (!fHasTTFonts) { return TGX11::SetTextFont(fontname, mode); - - if (gDebug > 0) - printf("SetTextFont: %s (%s)\n", fontname, mode==kLoad?"kLoad":"kCheck"); - - if (!fontname || !fontname[0]) { - Error("SetTextFont", "no font name specified"); - if (mode == kCheck) return 1; - Warning("SetTextFont", "using default font %s", fFontName[0]); - fCurFontIdx = 0; // use font 0 (default font, set in ctor) - return 0; - } - - const char *basename = gSystem->BaseName(fontname); - - // check if font is in cache - int i; - for (i = 0; i < fFontCount; i++) { - if (!strcmp(fFontName[i], basename)) { - if (mode == kCheck) return 0; - fCurFontIdx = i; - return 0; - } - } - - // enough space in cache to load font? - if (fFontCount >= kTTMaxFonts) { - Error("SetTextFont", "too many fonts opened (increase kTTMaxFont = %d)", - kTTMaxFonts); - if (mode == kCheck) return 1; - Warning("SetTextFont", "using default font %s", fFontName[0]); - fCurFontIdx = 0; // use font 0 (default font, set in ctor) - return 0; + } else { + return TTF::SetTextFont(fontname); } - // try to load font (font must be in Root.TTFontPath resource) -#ifndef TTFFONTDIR - const char *ttpath = gEnv->GetValue("Root.TTFontPath", - "$(ROOTSYS)/ttf/fonts"); -#else - const char *ttpath = gEnv->GetValue("Root.TTFontPath", - TTFFONTDIR ); -#endif + // set initial text size + SetTextSize(fTextSize); +} - char *ttfont = gSystem->Which(ttpath, fontname, kReadPermission); +//______________________________________________________________________________ +void TGX11TTF::SetTextSize(Float_t textsize) +{ + // Set current text size. - if (!ttfont) { - Error("SetTextFont", "font file %s not found in path", fontname); - if (mode == kCheck) return 1; - if (fFontCount) { - Warning("SetTextFont", "using default font %s", fFontName[0]); - fCurFontIdx = 0; // use font 0 (default font, set in ctor) - return 0; - } else { - Error("SetTextFont", "switching back to X11 fonts"); - fHasTTFonts = kFALSE; - return 1; - } - } - - if (mode == kCheck) { - delete [] ttfont; - return 0; - } - - Int_t res = 96; // dpi for SVGA display - TT_Error error; - TT_Face *tface = new TT_Face; - - error = TT_Open_Face(*fEngine, ttfont, tface); - if (error) { - Error("SetTextFont", "error loading font %s", ttfont); - delete [] ttfont; - delete tface; - if (mode == kCheck) return 1; - if (fFontCount) { - Warning("SetTextFont", "using default font %s", fFontName[0]); - fCurFontIdx = 0; // use font 0 (default font, set in ctor) - return 0; - } else { - Error("SetTextFont", "switching back to X11 fonts"); - fHasTTFonts = kFALSE; - return 1; - } - } - delete [] ttfont; - - fFontName[fFontCount] = StrDup(basename); - fCurFontIdx = fFontCount; - fFace[fCurFontIdx] = tface; - fFontCount++; - - // get face properties and allocate preload arrays - fProperties[fCurFontIdx] = new TT_Face_Properties; - error = TT_Get_Face_Properties(*tface, fProperties[fCurFontIdx]); - if (error) { - SafeDelete(fProperties[fCurFontIdx]); - Error("SetTextFont", "error getting properties for font %s", basename); - goto fail; - } - - // create glyph - fGlyph[fCurFontIdx] = new TT_Glyph; - error = TT_New_Glyph(*tface, fGlyph[fCurFontIdx]); - if (error) { - SafeDelete(fGlyph[fCurFontIdx]); - Error("SetTextFont", "error creating glyph for font %s", basename); - goto fail; - } - - // create instance - fInstance[fCurFontIdx] = new TT_Instance; - error = TT_New_Instance(*tface, fInstance[fCurFontIdx]); - if (error) { - SafeDelete(fInstance[fCurFontIdx]); - Error("SetTextFont", "error creating instance for font %s", basename); - goto fail; - } - - // set device resolution - error = TT_Set_Instance_Resolutions(*fInstance[fCurFontIdx], res, res); - if (error) { - Error("SetTextFont", "could not set device resolutions for font %s", basename); - goto fail; - } - - fCharMap[fCurFontIdx] = 0; - - // set initial text size - SetTextSize(fTextSize); - - return 0; - -fail: - TT_Close_Face(*tface); - fFontCount--; - delete [] fFontName[fFontCount]; - SafeDelete(fFace[fCurFontIdx]); - if (mode == kCheck) return 1; - if (fFontCount) { - Warning("SetTextFont", "using default font %s", fFontName[0]); - fCurFontIdx = 0; // use font 0 (default font, set in ctor) - return 0; - } else { - Error("SetTextFont", "switching back to X11 fonts"); - fHasTTFonts = kFALSE; - return 1; - } -} - -//______________________________________________________________________________ -void TGX11TTF::SetTextFont(Font_t fontnumber) -{ - // Set specified font. - // List of the currently supported fonts (screen and PostScript) - // ============================================================= - // Font ID X11 TTF - // 1 : times-medium-i-normal timesi.ttf - // 2 : times-bold-r-normal timesbd.ttf - // 3 : times-bold-i-normal timesi.ttf - // 4 : helvetica-medium-r-normal arial.ttf - // 5 : helvetica-medium-o-normal ariali.ttf - // 6 : helvetica-bold-r-normal arialbd.ttf - // 7 : helvetica-bold-o-normal arialbi.ttf - // 8 : courier-medium-r-normal cour.ttf - // 9 : courier-medium-o-normal couri.ttf - // 10 : courier-bold-r-normal courbd.ttf - // 11 : courier-bold-o-normal courbi.ttf - // 12 : symbol-medium-r-normal symbol.ttf - // 13 : times-medium-r-normal times.ttf - // 14 : wingding.ttf - -#ifndef R__TTFROT - if (!fHasTTFonts || fTextAngle != 0.) { -#else - if (!fHasTTFonts) { -#endif - TGX11::SetTextFont(fontnumber); - return; - } - - fTextFont = fontnumber; - - const char *fontname; - - switch (fontnumber/10) { - - case 1: - fontname = "timesi.ttf"; - break; - case 2: - fontname = "timesbd.ttf"; - break; - case 3: - fontname = "timesbi.ttf"; - break; - case 4: - fontname = "arial.ttf"; - break; - case 5: - fontname = "ariali.ttf"; - break; - case 6: - fontname = "arialbd.ttf"; - break; - case 7: - fontname = "arialbi.ttf"; - break; - case 8: - fontname = "cour.ttf"; - break; - case 9: - fontname = "couri.ttf"; - break; - case 10: - fontname = "courbd.ttf"; - break; - case 11: - fontname = "courbi.ttf"; - break; - case 12: - fontname = "symbol.ttf"; - break; - case 13: - fontname = "times.ttf"; - break; - case 14: - fontname = "wingding.ttf"; - break; - default: - fontname = "arialbd.ttf"; - break; - } - - SetTextFont((char *)fontname, kLoad); -} - -//______________________________________________________________________________ -void TGX11TTF::SetTextSize(Float_t textsize) -{ - // Set current text size. - -#ifndef R__TTFROT - if (!fHasTTFonts || fTextAngle != 0.) { -#else + fTextSize = textsize; if (!fHasTTFonts) { -#endif TGX11::SetTextSize(textsize); -#ifndef R__TTFROT - if (!fHasTTFonts) -#endif - return; - } - - if (gDebug > 0) - printf("SetTextSize: %f\n", textsize); - - fTextSize = textsize; - - if (fTextSize < 0) return; - - if (fCurFontIdx < 0 || fFontCount <= fCurFontIdx) { - Error("SetTextSize", "current font index out of bounds"); - fCurFontIdx = 0; // use font 0 (default font, set in ctor) - return; - } - - Int_t tsize = TMath::Nint(fTextSize * kScale) << 6; - TT_Error error = TT_Set_Instance_CharSize(*fInstance[fCurFontIdx], tsize); - if (error) - Error("SetTextSize", "could not set new size in instance"); -} - -//______________________________________________________________________________ -TTChar *TGX11TTF::GetChar(UInt_t code, UInt_t size, Float_t angle, Bool_t force) -{ - // Get a TTChar corresponding to the char code, size and current font. - // If force is true (the default) and the cache is full the lru char - // will be removed from the cache. If false it returns 0. - - // look for char in cache - TTChar *c = LookupChar(code, size, angle, fFontName[fCurFontIdx]); - - if (!c) { - while (fCacheCount >= kCacheSize) { - - if (!force) return 0; - - // get least recent used char - TTChar *lru = (TTChar *)fLRU->LastLink()->GetObject(); - - // remove from lru list and hashtable - fLRU->Remove(lru->fLink); - fCharCache->Remove(lru); - - delete lru; - fCacheCount--; - } - - // create new char - if (angle == 0.) - c = AllocChar(code, size, fFontName[fCurFontIdx]); - else - c = AllocRotatedChar(code, size, angle, fFontName[fCurFontIdx]); - } - - return c; -} - -//______________________________________________________________________________ -TTChar *TGX11TTF::LookupChar(UInt_t code, UInt_t size, Float_t angle, const char *fontname) -{ - // Find TTChar corresponding to the char code, size and font in cache. - // Returns 0 if not in cache. - - TTChar tmp; - tmp.fCode = code; - tmp.fSize = size; - tmp.fAngle = angle; - tmp.fFontName = fontname; - - TTChar *c = (TTChar *) fCharCache->FindObject(&tmp); - - if (c) { - // when found in cache bring to front of lru list - fLRU->Remove(c->fLink); - fLRU->AddFirst(c); - c->fLink = fLRU->FirstLink(); - fCacheHits++; - } else - fCacheMisses++; - - return c; -} - -//______________________________________________________________________________ -TTChar *TGX11TTF::AllocChar(UInt_t code, UInt_t size, const char *fontname) -{ - // Allocate a TTChar object corresponding to the char code, size and font. - // TTChar is added to the cache for later reuse. In case of failure - // return 0. - - Short_t unicode = CharToUnicode(code); - - if (!unicode) - return 0; - - TT_Error error; - - if ((error = LoadTrueTypeChar(unicode))) { - Error("AllocChar", "LoadTrueTypeChar %c (0x%04x) failed for font %s (err=%d)", - isprint(unicode) ? unicode : '?', unicode, fontname, error); - //fprintf(stderr, "Reason: %s\n", TT_ErrToString18(error)); - return 0; - } - - TT_Glyph_Metrics metrics; - TT_Get_Glyph_Metrics(*fGlyph[fCurFontIdx], &metrics); - - // TT_Get_Glyph_Pixmap generates pixmap starting from FreeType - // origin (leftmost side, baseline). Because of this 3rd and 4th - // arguments are necessary. - // For X axis (3rd argument), we have to take metrics.bearingX as - // offset. Y axis must be shifted if there's descent box (image - // below the baseline). 4th argument is specified for that. - - TT_Raster_Map bitmap; - - bitmap.rows = int((metrics.bbox.yMax - metrics.bbox.yMin) >> 6); - bitmap.rows += 2; // insurance to cope with number-round error - bitmap.width = int((metrics.bbox.xMax - metrics.bbox.xMin) >> 6); - bitmap.width += 2; // insurance to cope with number-round error - if (fSmoothing) - bitmap.cols = (bitmap.width+3) & -4; - else - bitmap.cols = (bitmap.width+7) >> 3; - bitmap.flow = TT_Flow_Down; - bitmap.size = (long)bitmap.cols * bitmap.rows; - bitmap.bitmap = (void *)new char[bitmap.size]; - memset(bitmap.bitmap, 0, (size_t)bitmap.size); - - // be very careful about TTCeil/TTFloor, must be multiples of 64 otherwise - // hinting will be ruined if this is not the case - - if (fSmoothing) - TT_Get_Glyph_Pixmap(*fGlyph[fCurFontIdx], &bitmap, TTCeil(-metrics.bearingX), - TTCeil(metrics.bbox.yMax - metrics.bbox.yMin - metrics.bearingY)); - else - TT_Get_Glyph_Bitmap(*fGlyph[fCurFontIdx], &bitmap, TTCeil(-metrics.bearingX), - TTCeil(metrics.bbox.yMax - metrics.bbox.yMin - metrics.bearingY)); - - TTChar *c = new TTChar; - - c->fCode = code; - c->fSize = size; - c->fAngle = 0.; - c->fWidth = bitmap.width; - c->fBwidth = bitmap.cols; - c->fHeight = bitmap.rows; - - // ascent must be derived from descent, to avoid number-rounding errors - c->fDescent = int(TTCeil(metrics.bbox.yMax - metrics.bbox.yMin - metrics.bearingY) >> 6); - c->fAscent = bitmap.rows - c->fDescent; - c->fXoff = int(metrics.bearingX >> 6); - if (c->fXoff < 0) c->fXoff = 0; - c->fFontName = fontname; - c->fCharlen = int(metrics.advance >> 6); - c->fBitmap = (UChar_t *)bitmap.bitmap; - - fCharCache->Add(c); - fLRU->AddFirst(c); - c->fLink = fLRU->FirstLink(); - - fCacheCount++; - - return c; -} - -//______________________________________________________________________________ -TTChar *TGX11TTF::AllocRotatedChar(UInt_t code, UInt_t size, Float_t angle, - const char *fontname) -{ - // Allocate a TTChar object corresponding to the char code, size, angle - // and font. TTChar is added to the cache for later reuse. In case of failure - // return 0. - - Short_t unicode = CharToUnicode(code); - - if (!unicode) - return 0; - - TT_Error error; - - if ((error = LoadTrueTypeChar(unicode))) { - Error("AllocChar", "LoadTrueTypeChar %c (0x%04x) failed for font %s (err=%d)", - isprint(unicode) ? unicode : '?', unicode, fontname, error); - //fprintf(stderr, "Reason: %s\n", TT_ErrToString18(error)); - return 0; - } - - TT_Glyph_Metrics metrics; - TT_Get_Glyph_Metrics(*fGlyph[fCurFontIdx], &metrics); - - // access its outline - TT_Outline outline; - TT_Get_Glyph_Outline(*fGlyph[fCurFontIdx], &outline); - - // copy outline and rotate it - TT_Outline toutline; - TT_New_Outline(outline.n_points, outline.n_contours, &toutline); - TT_Copy_Outline(&outline, &toutline); - TT_Transform_Outline(&toutline, fRotMatrix); - - // get bounding box and grid-fit it - TT_BBox bbox; - TT_Get_Outline_BBox(&toutline, &bbox); - - bbox.xMin = TTFloor(bbox.xMin); - bbox.yMin = TTFloor(bbox.yMin); - bbox.xMax = TTCeil(bbox.xMax); - bbox.yMax = TTCeil(bbox.yMax); - - TT_Translate_Outline(&toutline, -bbox.xMin, -bbox.yMin); - - // TT_Get_Outline_Pixmap generates pixmap starting from FreeType - // origin (leftmost side, baseline). Because of this 3rd and 4th - // arguments are necessary. - // For X axis (3rd argument), we have to take metrics.bearingX as - // offset. Y axis must be shifted if there's descent box (image - // below the baseline). 4th argument is specified for that. - - TT_Raster_Map bitmap; - - bitmap.rows = int((bbox.yMax - bbox.yMin) >> 6); - bitmap.rows += 2; // insurance to cope with number-round error - bitmap.width = int((bbox.xMax - bbox.xMin) >> 6); - bitmap.width += 2; // insurance to cope with number-round error - if (fSmoothing) - bitmap.cols = (bitmap.width+3) & -4; - else - bitmap.cols = (bitmap.width+7) >> 3; - bitmap.flow = TT_Flow_Down; - bitmap.size = (long)bitmap.cols * bitmap.rows; - bitmap.bitmap = (void *)new char[bitmap.size]; - memset(bitmap.bitmap, 0, (size_t)bitmap.size); - - // be very careful about TTCeil/TTFloor, must be multiples of 64 otherwise - // hinting will be ruined if this is not the case - - if (fSmoothing) - TT_Get_Outline_Pixmap(*fEngine, &toutline, &bitmap); - else - TT_Get_Outline_Bitmap(*fEngine, &toutline, &bitmap); - - TTChar *c = new TTChar; - - c->fCode = code; - c->fSize = size; - c->fAngle = angle; - c->fWidth = bitmap.width; - c->fBwidth = bitmap.cols; - c->fHeight = bitmap.rows; - - // ascent must be derived from descent, to avoid number-rounding errors - c->fDescent = int(bbox.yMin >> 6); - c->fAscent = bitmap.rows - c->fDescent; - c->fXoff = int(bbox.xMin >> 6); - c->fFontName = fontname; - c->fCharlen = int(metrics.advance >> 6); - c->fBitmap = (UChar_t *)bitmap.bitmap; - - fCharCache->Add(c); - fLRU->AddFirst(c); - c->fLink = fLRU->FirstLink(); - - fCacheCount++; - - TT_Done_Outline(&toutline); - - return c; -} - -//______________________________________________________________________________ -Short_t TGX11TTF::CharToUnicode(UInt_t code) -{ - // Map char to unicode. Returns 0 in case no mapping exists. - - if (!fCharMap[fCurFontIdx]) { - UShort_t i, platform, encoding; - - fCharMap[fCurFontIdx] = new TT_CharMap; - - // first look for a unicode charmap - Int_t n = fProperties[fCurFontIdx]->num_CharMaps; - - for (i = 0; i < n; i++) { - TT_Get_CharMap_ID(*fFace[fCurFontIdx], i, &platform, &encoding); - - if ((platform == 3 && encoding == 1) || - (platform == 0 && encoding == 0) || - (platform == 1 && encoding == 0 && - !strcmp(fFontName[fCurFontIdx],"symbol.ttf"))) { - TT_Get_CharMap(*fFace[fCurFontIdx], i, fCharMap[fCurFontIdx]); - return TT_Char_Index(*fCharMap[fCurFontIdx], (Short_t) code); - } - } - - if (gDebug > 0) - Warning("CharToUnicode", "the fontfile %s doesn't contain any unicode " - "mapping table\n", fFontName[fCurFontIdx]); - } - - return TT_Char_Index(*fCharMap[fCurFontIdx], (Short_t) code); -} - -//______________________________________________________________________________ -Int_t TGX11TTF::LoadTrueTypeChar(Int_t idx) -{ - // Load the True Type character. - - int flags; - - flags = TTLOAD_SCALE_GLYPH; - if (fHinting) - flags |= TTLOAD_HINT_GLYPH; - - return TT_Load_Glyph(*fInstance[fCurFontIdx], *fGlyph[fCurFontIdx], idx, flags); -} - -//______________________________________________________________________________ -XImage *TGX11TTF::GetBackground(Int_t x, Int_t y, UInt_t w, UInt_t h) -{ - // Get the background of the current window in an XImage. - - XWindow_t *cws = GetCurrentWindow(); - - if (x < 0) { - w += x; - x = 0; - } - if (y < 0) { - h += y; - y = 0; - } - - if (x+w > cws->width) w = cws->width - x; - if (y+h > cws->height) h = cws->height - y; - - return XGetImage(fDisplay, cws->drawing, x, y, w, h, AllPlanes, ZPixmap); -} - -//______________________________________________________________________________ -Bool_t TGX11TTF::IsVisible(Int_t x, Int_t y, UInt_t w, UInt_t h) -{ - // If string falls outside window, there is probably no need to draw it. - - XWindow_t *cws = GetCurrentWindow(); - - if (x + (int)w <= 0 || x >= (int)cws->width) return kFALSE; - if (y + (int)h <= 0 || y >= (int)cws->height) return kFALSE; - - return kTRUE; -} - -//______________________________________________________________________________ -void TGX11TTF::DrawImage(TTChar *c, ULong_t fore, ULong_t back, XImage *xim, - Int_t bx, Int_t by) -{ - // Draw TTChar bitmap to xim image at position bx,by using specified - // foreground color. - - UChar_t d = 0, *s = c->fBitmap; - - if (fSmoothing) { - - static XColor col[5]; - XColor *bcol = 0, *bc; - Int_t x, y; - //UInt_t charlen = c->fCharlen; - UInt_t charlen = c->fWidth; - - // background kClear, i.e. transparent, we take as background color - // the average of the rgb values of all pixels covered by this character - if (back == (ULong_t) -1 && charlen) { - ULong_t r, g, b; - Int_t dots, dotcnt; - const Int_t maxdots = 50000; - - dots = Int_t(charlen * c->fHeight); - dots = dots > maxdots ? maxdots : dots; - bcol = new XColor[dots]; - if (!bcol) return; - bc = bcol; - dotcnt = 0; - for (y = 0; y < (int) c->fHeight; y++) { - for (x = 0; x < (int) charlen; x++, bc++) { - bc->pixel = XGetPixel(xim, bx + c->fXoff + x, by - c->fAscent + y); - bc->flags = DoRed | DoGreen | DoBlue; - if (++dotcnt >= maxdots) break; - } - } - QueryColors(fColormap, bcol, dots); - r = g = b = 0; - bc = bcol; - dotcnt = 0; - for (y = 0; y < (int) c->fHeight; y++) { - for (x = 0; x < (int) charlen; x++, bc++) { - r += bc->red; - g += bc->green; - b += bc->blue; - if (++dotcnt >= maxdots) break; - } - } - r /= dots; g /= dots; b /= dots; - bc = &col[0]; - if (bc->red == r && bc->green == g && bc->blue == b) - bc->pixel = back; - else { - bc->pixel = ~back; - bc->red = (UShort_t) r; - bc->green = (UShort_t) g; - bc->blue = (UShort_t) b; - } - } - delete [] bcol; - - // if fore or background have changed from previous character - // recalculate the 3 smooting colors (interpolation between fore- - // and background colors) - if (fore != col[4].pixel || back != col[0].pixel) { - col[4].pixel = fore; - col[4].flags = DoRed|DoGreen|DoBlue; - if (back != (ULong_t) -1) { - col[3].pixel = back; - col[3].flags = DoRed | DoGreen | DoBlue; - QueryColors(fColormap, &col[3], 2); - col[0] = col[3]; - } else - QueryColors(fColormap, &col[4], 1); - - // interpolate between fore and backgound colors - for (x = 3; x > 0; x--) { - col[x].red = (col[4].red *x + col[0].red *(4-x)) /4; - col[x].green = (col[4].green*x + col[0].green*(4-x)) /4; - col[x].blue = (col[4].blue *x + col[0].blue *(4-x)) /4; - if (!AllocColor(fColormap, &col[x])) { - Warning("DrawImage", "cannot allocate smoothing color"); - col[x].pixel = col[x+1].pixel; - } - } - } - - // put smoothed character, character pixmap values are an index - // into the 5 colors used for aliasing (4 = foreground, 0 = background) - for (y = 0; y < (int) c->fHeight; y++) { - for (x = 0; x < (int) c->fBwidth; x++) { - d = *s++; - if (d && x < (int) c->fWidth) { - ULong_t p = col[d].pixel; - XPutPixel(xim, bx + c->fXoff + x, by - c->fAscent + y, p); - } - } - } - } else { - - // no smoothing, just put charachter using foreground color - for (int y = 0; y < (int) c->fHeight; y++) { - int n = 0; - for (int x = 0; x < (int) c->fWidth; x++) { - if (n == 0) d = *s++; - if (TESTBIT(d,7-n)) { - XPutPixel(xim, bx + c->fXoff + x, by - c->fAscent + y, fore); - } - if (++n == (int) kBitsPerByte) n = 0; - } - } - } -} - -//______________________________________________________________________________ -void TGX11TTF::SetRotationMatrix(Float_t angle) -{ - // Set the rotation matrix used to rotate the font outlines. - - //TT_Set_Instance_Transform_Flags( instance, 1, 0 ); - - if (fRotMatrix) { - SafeDelete(fRotMatrix); - } - fRotMatrix = new TT_Matrix; - - angle = Float_t(angle * TMath::Pi() / 180.); - - fRotMatrix->xx = (TT_Fixed) (TMath::Cos(angle) * (1<<16)); - fRotMatrix->xy = (TT_Fixed) (TMath::Sin(angle) * (1<<16)); - fRotMatrix->yx = -fRotMatrix->xy; - fRotMatrix->yy = fRotMatrix->xx; -} - -//______________________________________________________________________________ -void TGX11TTF::SetHinting(Bool_t state) -{ - // Set hinting flag. If status changes clear cache. - - if (fHinting != state) { - ClearCache(); - fHinting = state; - } -} - -//______________________________________________________________________________ -void TGX11TTF::SetSmoothing(Bool_t state) -{ - // Set smoothing (anit-aliasing) flag. If status changes clear cache. - - if (state && fDepth <= 8) - Warning("SetSmoothing", "the colormap might not have enough free color " - "cells to fully support smoothing"); - - if (fSmoothing != state) { - ClearCache(); - fSmoothing = state; + TTF::SetTextSize(textsize); } } -- GitLab