Logo ROOT   6.08/07
Reference Guide
TGString.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 05/01/98
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TGString
13 #define ROOT_TGString
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGString and TGHotString //
19 // //
20 // TGString wraps a TString and adds some graphics routines like //
21 // drawing, size of string on screen depending on font, etc. //
22 // TGHotString is a string with a "hot" character unerlined. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #ifndef ROOT_TString
27 #include "TString.h"
28 #endif
29 #ifndef ROOT_GuiTypes
30 #include "GuiTypes.h"
31 #endif
32 
33 
34 class TGString : public TString {
35 
36 public:
37  TGString() : TString() { }
38  TGString(const char *s) : TString(s) { }
39  TGString(Int_t number) : TString() { *this += number; }
40  TGString(const TGString *s);
41  virtual ~TGString() { }
42 
43  Int_t GetLength() const { return Length(); }
44  const char *GetString() const { return Data(); }
45  virtual void SetString(const char *s) { *this = s; }
46 
47  virtual void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y);
48  virtual void DrawWrapped(Drawable_t id, GContext_t gc,
49  Int_t x, Int_t y, UInt_t w, FontStruct_t font);
50  virtual Int_t GetLines(FontStruct_t font, UInt_t w);
51 
52  ClassDef(TGString,0) // Graphics string
53 };
54 
55 
56 class TGHotString : public TGString {
57 
58 protected:
59  char fHotChar; // hot character
60  Int_t fHotPos; // position of hot character
61 
62  GContext_t fLastGC; // context used during last drawing
63  Int_t fOff1; // variable used during drawing (cache)
64  Int_t fOff2; // variable used during drawing (cache)
65 
66  void DrawHotChar(Drawable_t id, GContext_t gc, Int_t x, Int_t y);
67 
68 public:
69  TGHotString(const char *s);
70 
71  Int_t GetHotChar() const { return fHotChar; }
72  Int_t GetHotPos() const { return fHotPos; }
73  virtual void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y);
74  virtual void DrawWrapped(Drawable_t id, GContext_t gc,
75  Int_t x, Int_t y, UInt_t w, FontStruct_t font);
76 
77  ClassDef(TGHotString,0) // Graphics string with hot character
78 };
79 
80 #endif
Handle_t FontStruct_t
Definition: GuiTypes.h:40
virtual Int_t GetLines(FontStruct_t font, UInt_t w)
Get number of lines of width w the string would take using a certain font.
Definition: TGString.cxx:102
char fHotChar
Definition: TGString.h:59
Handle_t GContext_t
Definition: GuiTypes.h:39
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
Handle_t Drawable_t
Definition: GuiTypes.h:32
TGString(const char *s)
Definition: TGString.h:38
Int_t fHotPos
Definition: TGString.h:60
Int_t GetHotChar() const
Definition: TGString.h:71
TGString(Int_t number)
Definition: TGString.h:39
Int_t fOff2
Definition: TGString.h:64
Double_t x[n]
Definition: legend1.C:17
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t GetHotPos() const
Definition: TGString.h:72
TGString()
Definition: TGString.h:37
unsigned int UInt_t
Definition: RtypesCore.h:42
Ssiz_t Length() const
Definition: TString.h:390
const char * GetString() const
Definition: TGString.h:44
Double_t y[n]
Definition: legend1.C:17
virtual void SetString(const char *s)
Definition: TGString.h:45
virtual ~TGString()
Definition: TGString.h:41
Int_t fOff1
Definition: TGString.h:63
virtual void DrawWrapped(Drawable_t id, GContext_t gc, Int_t x, Int_t y, UInt_t w, FontStruct_t font)
Draw a string in a column with width w.
Definition: TGString.cxx:60
GContext_t fLastGC
Definition: TGString.h:62
Int_t GetLength() const
Definition: TGString.h:43
virtual void Draw(Drawable_t id, GContext_t gc, Int_t x, Int_t y)
Draw string.
Definition: TGString.cxx:51
const char * Data() const
Definition: TString.h:349