#ifndef ROOT_TGFont
#define ROOT_TGFont
#ifndef ROOT_TNamed
#include "TNamed.h"
#endif
#ifndef ROOT_TGObject
#include "TGObject.h"
#endif
#ifndef ROOT_TRefCnt
#include "TRefCnt.h"
#endif
class THashTable;
class TObjString;
class TGFont;
enum ETextLayoutFlags {
kTextWholeWords = BIT(0),
kTextAtLeastOne = BIT(1),
kTextPartialOK = BIT(2),
kTextIgnoreTabs = BIT(3),
kTextIgnoreNewlines = BIT(4)
};
enum EFontWeight {
kFontWeightNormal = 0,
kFontWeightMedium = 0,
kFontWeightBold = 1,
kFontWeightLight = 2,
kFontWeightDemibold = 3,
kFontWeightBlack = 4,
kFontWeightUnknown = -1
};
enum EFontSlant {
kFontSlantRoman = 0,
kFontSlantItalic = 1,
kFontSlantOblique = 2,
kFontSlantUnknown = -1
};
struct FontMetrics_t {
Int_t fAscent;
Int_t fDescent;
Int_t fLinespace;
Int_t fMaxWidth;
Bool_t fFixed;
};
struct FontAttributes_t {
const char *fFamily;
Int_t fPointsize;
Int_t fWeight;
Int_t fSlant;
Int_t fUnderline;
Int_t fOverstrike;
FontAttributes_t():
fFamily (0),
fPointsize (0),
fWeight (kFontWeightNormal),
fSlant (kFontSlantRoman),
fUnderline (0),
fOverstrike(0) { }
FontAttributes_t(const FontAttributes_t& f):
fFamily (f.fFamily),
fPointsize (f.fPointsize),
fWeight (f.fWeight),
fSlant (f.fSlant),
fUnderline (f.fUnderline),
fOverstrike(f.fOverstrike) { }
FontAttributes_t& operator=(const FontAttributes_t& f)
{
fFamily = f.fFamily;
fPointsize = f.fPointsize;
fWeight = f.fWeight;
fSlant = f.fSlant;
fUnderline = f.fUnderline;
fOverstrike = f.fOverstrike;
return *this;
}
};
struct LayoutChunk_t;
class TGTextLayout : public TObject {
friend class TGFont;
protected:
const TGFont *fFont;
const char *fString;
Int_t fWidth;
Int_t fNumChunks;
LayoutChunk_t *fChunks;
TGTextLayout(const TGTextLayout &tlayout);
void operator=(const TGTextLayout &tlayout);
public:
TGTextLayout(): fFont(NULL), fString(""), fWidth(0), fNumChunks(0), fChunks(NULL) {}
virtual ~TGTextLayout();
void DrawText(Drawable_t dst, GContext_t gc, Int_t x, Int_t y,
Int_t firstChar, Int_t lastChar) const;
void UnderlineChar(Drawable_t dst, GContext_t gc,
Int_t x, Int_t y, Int_t underline) const;
Int_t PointToChar(Int_t x, Int_t y) const;
Int_t CharBbox(Int_t index, Int_t *x, Int_t *y, Int_t *w, Int_t *h) const;
Int_t DistanceToText(Int_t x, Int_t y) const;
Int_t IntersectText(Int_t x, Int_t y, Int_t w, Int_t h) const;
void ToPostscript(TString *dst) const;
ClassDef(TGTextLayout,0)
};
class TGFont : public TNamed, public TRefCnt {
friend class TGFontPool;
friend class TGTextLayout;
private:
FontStruct_t fFontStruct;
FontH_t fFontH;
FontMetrics_t fFM;
FontAttributes_t fFA;
TObjString *fNamedHash;
Int_t fTabWidth;
Int_t fUnderlinePos;
Int_t fUnderlineHeight;
char fTypes[256];
Int_t fWidths[256];
Int_t fBarHeight;
protected:
TGFont(const char *name)
: TNamed(name,""), TRefCnt(), fFontStruct(0), fFontH(0), fFM(),
fFA(), fNamedHash(0), fTabWidth(0), fUnderlinePos(0), fUnderlineHeight(0), fBarHeight(0)
{
SetRefCount(1);
}
TGFont(const TGFont &font);
void operator=(const TGFont &font);
LayoutChunk_t *NewChunk(TGTextLayout *layout, int *maxPtr,
const char *start, int numChars,
int curX, int newX, int y) const;
public:
virtual ~TGFont();
FontH_t GetFontHandle() const { return fFontH; }
FontStruct_t GetFontStruct() const { return fFontStruct; }
FontStruct_t operator()() const;
void GetFontMetrics(FontMetrics_t *m) const;
FontAttributes_t GetFontAttributes() const { return fFA; }
Int_t PostscriptFontName(TString *dst) const;
Int_t TextWidth(const char *string, Int_t numChars = -1) const;
Int_t XTextWidth(const char *string, Int_t numChars = -1) const;
Int_t TextHeight() const { return fFM.fLinespace; }
void UnderlineChars(Drawable_t dst, GContext_t gc,
const char *string, Int_t x, Int_t y,
Int_t firstChar, Int_t lastChar) const;
TGTextLayout *ComputeTextLayout(const char *string, Int_t numChars,
Int_t wrapLength, Int_t justify, Int_t flags,
UInt_t *width, UInt_t *height) const;
Int_t MeasureChars(const char *source, Int_t numChars, Int_t maxLength,
Int_t flags, Int_t *length) const;
void DrawCharsExp(Drawable_t dst, GContext_t gc, const char *source,
Int_t numChars, Int_t x, Int_t y) const;
void DrawChars(Drawable_t dst, GContext_t gc, const char *source,
Int_t numChars, Int_t x, Int_t y) const;
void Print(Option_t *option="") const;
virtual void SavePrimitive(ostream &out, Option_t * = "");
ClassDef(TGFont,0)
};
struct FontStateMap_t;
struct XLFDAttributes_t;
class TGFontPool : public TGObject {
private:
THashTable *fList;
THashTable *fUidTable;
THashTable *fNamedTable;
TGFontPool(const TGFontPool& fp);
TGFontPool& operator=(const TGFontPool& fp);
protected:
const char *GetUid(const char *string);
Bool_t ParseXLFD(const char *string, XLFDAttributes_t *xa);
TGFont *GetFontFromAttributes(FontAttributes_t *fa, TGFont *fontPtr);
int FindStateNum(const FontStateMap_t *map, const char *strKey);
const char *FindStateString(const FontStateMap_t *map, int numKey);
Bool_t FieldSpecified(const char *field);
TGFont *GetNativeFont(const char *name, Bool_t fixedDefault = kTRUE);
TGFont *MakeFont(TGFont *font, FontStruct_t fontStruct, const char *fontName);
public:
TGFontPool(TGClient *client);
virtual ~TGFontPool();
TGFont *GetFont(const char *font, Bool_t fixedDefault = kTRUE);
TGFont *GetFont(const TGFont *font);
TGFont *GetFont(FontStruct_t font);
TGFont *GetFont(const char *family, Int_t ptsize, Int_t weight, Int_t slant);
void FreeFont(const TGFont *font);
TGFont *FindFont(FontStruct_t font) const;
TGFont *FindFontByHandle(FontH_t font) const;
char **GetAttributeInfo(const FontAttributes_t *fa);
void FreeAttributeInfo(char **info);
char **GetFontFamilies();
void FreeFontFamilies(char **f);
Bool_t ParseFontName(const char *string, FontAttributes_t *fa);
const char *NameOfFont(TGFont *font);
void Print(Option_t *option="") const;
ClassDef(TGFontPool,0)
};
#endif
Last change: Wed Jun 25 08:29:10 2008
Last generated: 2008-06-25 08:29
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.