TGX11TTF.h

Go to the documentation of this file.
00001 // @(#)root/x11ttf:$Id: TGX11TTF.h 20882 2007-11-19 11:31:26Z rdm $
00002 // Author: Olivier Couet     01/10/02
00003 // Author: Fons Rademakers   21/11/98
00004 
00005 /*************************************************************************
00006  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00007  * All rights reserved.                                                  *
00008  *                                                                       *
00009  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00010  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00011  *************************************************************************/
00012 
00013 #ifndef ROOT_TGX11TTF
00014 #define ROOT_TGX11TTF
00015 
00016 
00017 //////////////////////////////////////////////////////////////////////////
00018 //                                                                      //
00019 // TGX11TTF                                                             //
00020 //                                                                      //
00021 // Interface to low level X11 (Xlib). This class gives access to basic  //
00022 // X11 graphics via the parent class TGX11. However, all text and font  //
00023 // handling is done via the Freetype TrueType library. When the         //
00024 // shared library containing this class is loaded the global gVirtualX  //
00025 // is redirected to point to this class.                                //
00026 //                                                                      //
00027 //////////////////////////////////////////////////////////////////////////
00028 
00029 #ifndef ROOT_TGX11
00030 #include "TGX11.h"
00031 #endif
00032 
00033 #ifndef ROOT_TTF
00034 #include "TTF.h"
00035 #endif
00036 
00037 #ifndef ROOT_RConfigure
00038 #include "RConfigure.h"
00039 #endif
00040 
00041 #ifdef R__HAS_XFT
00042 class TXftFontHash;
00043 #endif
00044 
00045 
00046 class TGX11TTF : public TGX11 {
00047 
00048 private:
00049    enum EAlign { kNone, kTLeft, kTCenter, kTRight, kMLeft, kMCenter, kMRight,
00050                         kBLeft, kBCenter, kBRight };
00051 
00052    FT_Vector   fAlign;                 // alignment vector
00053 #ifdef R__HAS_XFT
00054    TXftFontHash  *fXftFontHash;        // hash table for Xft fonts
00055 #endif
00056 
00057    void    Align(void);
00058    void    DrawImage(FT_Bitmap *source, ULong_t fore, ULong_t back, XImage *xim,
00059                      Int_t bx, Int_t by);
00060    Bool_t  IsVisible(Int_t x, Int_t y, UInt_t w, UInt_t h);
00061    XImage *GetBackground(Int_t x, Int_t y, UInt_t w, UInt_t h);
00062    void    RenderString(Int_t x, Int_t y, ETextMode mode);
00063 
00064 public:
00065    TGX11TTF(const TGX11 &org);
00066    virtual ~TGX11TTF() { }
00067 
00068    Bool_t Init(void *display);
00069    void   DrawText(Int_t x, Int_t y, Float_t angle, Float_t mgn,
00070                    const char *text, ETextMode mode);
00071    void   SetTextFont(Font_t fontnumber);
00072    Int_t  SetTextFont(char *fontname, ETextSetMode mode);
00073    void   SetTextSize(Float_t textsize);
00074 
00075 #ifdef R__HAS_XFT
00076    //---- Methods used text/fonts handling via Xft -----
00077    //void         SetClipRectangles(GContext_t gc, Int_t x, Int_t y, Rectangle_t *recs, Int_t n);
00078    FontStruct_t LoadQueryFont(const char *font_name);
00079    void         DeleteFont(FontStruct_t fs);
00080    void         DrawString(Drawable_t id, GContext_t gc, Int_t x, Int_t y, const char *s, Int_t len);
00081    Int_t        TextWidth(FontStruct_t font, const char *s, Int_t len);
00082    void         GetFontProperties(FontStruct_t font, Int_t &max_ascent, Int_t &max_descent);
00083 #endif
00084 
00085    static void  Activate();
00086 
00087    ClassDef(TGX11TTF,0)  //Interface to X11 + TTF font handling
00088 };
00089 
00090 #endif

Generated on Tue Jul 5 14:14:46 2011 for ROOT_528-00b_version by  doxygen 1.5.1