Logo ROOT   6.08/07
Reference Guide
TGGC.h
Go to the documentation of this file.
1 // @(#)root/gui:$Id$
2 // Author: Fons Rademakers 20/9/2000
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_TGGC
13 #define ROOT_TGGC
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TGGC and TGGCPool //
19 // //
20 // Encapsulate a graphics context used in the low level graphics. //
21 // TGGCPool provides a pool of graphics contexts. //
22 // //
23 //////////////////////////////////////////////////////////////////////////
24 
25 #ifndef ROOT_TGObject
26 #include "TGObject.h"
27 #endif
28 #ifndef ROOT_TRefCnt
29 #include "TRefCnt.h"
30 #endif
31 
32 class THashTable;
33 
34 
35 class TGGC : public TObject, public TRefCnt {
36 
37 friend class TGGCPool;
38 
39 protected:
40  GCValues_t fValues; // graphics context values + mask
41  GContext_t fContext; // graphics context handle
42 
43  TGGC(GCValues_t *values, Bool_t calledByGCPool);
44  void UpdateValues(GCValues_t *v);
45 
46  TString GetMaskString() const; //used in SavePrimitive()
47 
48 public:
49  TGGC(GCValues_t *values = 0);
50  TGGC(const TGGC &g);
51  virtual ~TGGC();
52  TGGC &operator=(const TGGC &rhs);
53 
54  GContext_t GetGC() const { return fContext; }
55  GContext_t operator()() const;
56 
57  void SetAttributes(GCValues_t *values);
59  void SetPlaneMask(ULong_t v);
60  void SetForeground(Pixel_t v);
61  void SetBackground(Pixel_t v);
62  void SetLineWidth(Int_t v);
63  void SetLineStyle(Int_t v);
64  void SetCapStyle(Int_t v);
65  void SetJoinStyle(Int_t v);
66  void SetFillStyle(Int_t v);
67  void SetFillRule(Int_t v);
68  void SetTile(Pixmap_t v);
69  void SetStipple(Pixmap_t v);
70  void SetTileStipXOrigin(Int_t v);
71  void SetTileStipYOrigin(Int_t v);
72  void SetFont(FontH_t v);
73  void SetSubwindowMode(Int_t v);
75  void SetClipXOrigin(Int_t v);
76  void SetClipYOrigin(Int_t v);
77  void SetClipMask(Pixmap_t v);
78  void SetDashOffset(Int_t v);
79  void SetDashList(const char v[], Int_t len);
80  void SetArcMode(Int_t v);
81 
82  const GCValues_t *GetAttributes() const { return &fValues; }
83  Mask_t GetMask() const { return fValues.fMask; }
84  EGraphicsFunction GetFunction() const { return fValues.fFunction; }
85  ULong_t GetPlaneMask() const { return fValues.fPlaneMask; }
86  Pixel_t GetForeground() const { return fValues.fForeground; }
87  Pixel_t GetBackground() const { return fValues.fBackground; }
88  Int_t GetLineWidth() const { return fValues.fLineWidth; }
89  Int_t GetLineStyle() const { return fValues.fLineStyle; }
90  Pixmap_t GetTile() const { return fValues.fTile; }
91  Pixmap_t GetStipple() const { return fValues.fStipple; }
92  Int_t GetTileStipXOrigin() const { return fValues.fTsXOrigin; }
93  Int_t GetTileStipYOrigin() const { return fValues.fTsYOrigin; }
94  Int_t GetSubwindowMode() const { return fValues.fSubwindowMode; }
95  FontH_t GetFont() const { return fValues.fFont; }
96  Bool_t GetGraphicsExposures() const { return fValues.fGraphicsExposures; }
97  Int_t GetClipXOrigin() const { return fValues.fClipXOrigin; }
98  Int_t GetClipYOrigin() const { return fValues.fClipYOrigin; }
99  Pixmap_t GetClipMask() const { return fValues.fClipMask; }
100  Int_t GetCapStyle() const { return fValues.fCapStyle; }
101  Int_t GetJoinStyle() const { return fValues.fJoinStyle; }
102  Int_t GetFillStyle() const { return fValues.fFillStyle; }
103  Int_t GetFillRule() const { return fValues.fFillRule; }
104  Int_t GetDashOffset() const { return fValues.fDashOffset; }
105  Int_t GetDashLen() const { return fValues.fDashLen; }
106  const char *GetDashes() const { return fValues.fDashes; }
107  Int_t GetArcMode() const { return fValues.fArcMode; }
108 
109  void Print(Option_t *option="") const;
110  void SavePrimitive(std::ostream &out, Option_t *option = "");
111 
112  ClassDef(TGGC,0) // Graphics context
113 };
114 
115 
116 class TGGCPool : public TGObject {
117 
118 friend class TGGC;
119 
120 private:
121  THashTable *fList; // hash table of graphics contexts in pool
122 
123  void ForceFreeGC(const TGGC *gc);
124  Int_t MatchGC(const TGGC *gc, GCValues_t *values);
125  void UpdateGC(TGGC *gc, GCValues_t *values);
126 
127 protected:
128  TGGCPool(const TGGCPool& gp) : TGObject(gp), fList(gp.fList) { }
130  {if(this!=&gp) {TGObject::operator=(gp); fList=gp.fList;}
131  return *this;}
132 
133 public:
134  TGGCPool(TGClient *client);
135  virtual ~TGGCPool();
136 
137  TGGC *GetGC(GCValues_t *values, Bool_t rw = kFALSE);
138  TGGC *GetGC(GContext_t gct);
139  void FreeGC(const TGGC *gc);
140  void FreeGC(GContext_t gc);
141 
142  TGGC *FindGC(const TGGC *gc);
143  TGGC *FindGC(GContext_t gc);
144 
145  void Print(Option_t *option="") const;
146 
147  ClassDef(TGGCPool,0) // Graphics context pool
148 };
149 
150 #endif
Int_t GetLineWidth() const
Definition: TGGC.h:88
Int_t fClipXOrigin
Definition: GuiTypes.h:246
TGGC(GCValues_t *values, Bool_t calledByGCPool)
Create a graphics context (only called via TGGCPool::GetGC()).
Definition: TGGC.cxx:36
Int_t fLineStyle
Definition: GuiTypes.h:231
Int_t GetClipYOrigin() const
Definition: TGGC.h:98
Char_t fDashes[8]
Definition: GuiTypes.h:250
void SetPlaneMask(ULong_t v)
Set plane mask.
Definition: TGGC.cxx:265
Pixmap_t fTile
Definition: GuiTypes.h:239
Int_t GetDashLen() const
Definition: TGGC.h:105
void SetTileStipYOrigin(Int_t v)
Y offset for tile or stipple operations.
Definition: TGGC.cxx:398
Int_t GetDashOffset() const
Definition: TGGC.h:104
void UpdateValues(GCValues_t *v)
Update values + mask.
Definition: TGGC.cxx:144
Int_t GetCapStyle() const
Definition: TGGC.h:100
FontH_t fFont
Definition: GuiTypes.h:243
UInt_t Mask_t
Definition: GuiTypes.h:42
const char Option_t
Definition: RtypesCore.h:62
Pixmap_t GetStipple() const
Definition: TGGC.h:91
Pixel_t GetBackground() const
Definition: TGGC.h:87
void SetForeground(Pixel_t v)
Set foreground color.
Definition: TGGC.cxx:276
Int_t GetTileStipXOrigin() const
Definition: TGGC.h:92
Definitions for TRefCnt, base class for reference counted objects.
Definition: TRefCnt.h:29
Int_t fTsYOrigin
Definition: GuiTypes.h:242
Handle_t GContext_t
Definition: GuiTypes.h:39
ULong_t fPlaneMask
Definition: GuiTypes.h:227
Basic string class.
Definition: TString.h:137
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
ULong_t GetPlaneMask() const
Definition: TGGC.h:85
const Bool_t kFALSE
Definition: Rtypes.h:92
Int_t fClipYOrigin
Definition: GuiTypes.h:247
Int_t fFillStyle
Definition: GuiTypes.h:235
Pixmap_t fClipMask
Definition: GuiTypes.h:248
TGGC & operator=(const TGGC &rhs)
Graphics context assignment operator.
Definition: TGGC.cxx:113
EGraphicsFunction fFunction
Definition: GuiTypes.h:226
GCValues_t fValues
Definition: TGGC.h:40
void SetFunction(EGraphicsFunction v)
Set graphics context drawing function.
Definition: TGGC.cxx:254
Handle_t FontH_t
Definition: GuiTypes.h:36
GContext_t fContext
Definition: TGGC.h:41
Definition: TGGC.h:116
TGGCPool(const TGGCPool &gp)
Definition: TGGC.h:128
void SetBackground(Pixel_t v)
Set background color.
Definition: TGGC.cxx:287
THashTable implements a hash table to store TObject's.
Definition: THashTable.h:39
#define ClassDef(name, id)
Definition: Rtypes.h:254
ULong_t Pixel_t
Definition: GuiTypes.h:41
Int_t fDashOffset
Definition: GuiTypes.h:249
ULong_t fForeground
Definition: GuiTypes.h:228
void SetArcMode(Int_t v)
Set arc mode (kArcChord, kArcPieSlice).
Definition: TGGC.cxx:501
void Print(Option_t *option="") const
Print graphics contexts info.
Definition: TGGC.cxx:512
Int_t GetFillStyle() const
Definition: TGGC.h:102
Pixmap_t GetClipMask() const
Definition: TGGC.h:99
Int_t GetTileStipYOrigin() const
Definition: TGGC.h:93
const GCValues_t * GetAttributes() const
Definition: TGGC.h:82
void SetStipple(Pixmap_t v)
Set 1 plane pixmap for stippling.
Definition: TGGC.cxx:376
Int_t fTsXOrigin
Definition: GuiTypes.h:241
TGGCPool & operator=(const TGGCPool &gp)
Definition: TGGC.h:129
Mask_t GetMask() const
Definition: TGGC.h:83
void SetClipYOrigin(Int_t v)
Y origin for clipping.
Definition: TGGC.cxx:453
void SetFont(FontH_t v)
Set font.
Definition: TGGC.cxx:409
Bool_t fGraphicsExposures
Definition: GuiTypes.h:245
void SetTileStipXOrigin(Int_t v)
X offset for tile or stipple operations.
Definition: TGGC.cxx:387
Int_t fDashLen
Definition: GuiTypes.h:251
void SetTile(Pixmap_t v)
Set tile pixmap for tiling operations.
Definition: TGGC.cxx:365
Pixel_t GetForeground() const
Definition: TGGC.h:86
SVector< double, 2 > v
Definition: Dict.h:5
friend class TGGCPool
Definition: TGGC.h:37
void SetFillStyle(Int_t v)
Set fill style (kFillSolid, kFillTiled, kFillStippled, kFillOpaeueStippled).
Definition: TGGC.cxx:343
void SetJoinStyle(Int_t v)
Set line join style (kJoinMiter, kJoinRound, kJoinBevel).
Definition: TGGC.cxx:331
virtual ~TGGC()
Delete graphics context.
Definition: TGGC.cxx:101
Int_t GetFillRule() const
Definition: TGGC.h:103
Pixmap_t fStipple
Definition: GuiTypes.h:240
THashTable * fList
Definition: TGGC.h:121
ULong_t fBackground
Definition: GuiTypes.h:229
void SetClipXOrigin(Int_t v)
X origin for clipping.
Definition: TGGC.cxx:442
void SavePrimitive(std::ostream &out, Option_t *option="")
Save graphics context info as a C++ statement(s) on output stream out.
Definition: TGGC.cxx:625
void SetLineStyle(Int_t v)
Set line style (kLineSolid, kLineOnOffDash, kLineDoubleDash).
Definition: TGGC.cxx:309
const char * GetDashes() const
Definition: TGGC.h:106
GContext_t GetGC() const
Definition: TGGC.h:54
unsigned long ULong_t
Definition: RtypesCore.h:51
Int_t fJoinStyle
Definition: GuiTypes.h:234
TString GetMaskString() const
Returns GC mask as a string - used in SavePrimitive().
Definition: TGGC.cxx:521
TGObject & operator=(const TGObject &tgo)
Definition: TGObject.h:43
Pixmap_t GetTile() const
Definition: TGGC.h:90
Int_t GetSubwindowMode() const
Definition: TGGC.h:94
Int_t fCapStyle
Definition: GuiTypes.h:232
Int_t GetLineStyle() const
Definition: TGGC.h:89
Int_t GetArcMode() const
Definition: TGGC.h:107
void SetAttributes(GCValues_t *values)
Set attributes as specified in the values structure.
Definition: TGGC.cxx:233
void SetGraphicsExposures(Bool_t v)
True if graphics exposure should be generated.
Definition: TGGC.cxx:431
Mother of all ROOT objects.
Definition: TObject.h:37
Int_t fFillRule
Definition: GuiTypes.h:237
Mask_t fMask
Definition: GuiTypes.h:252
FontH_t GetFont() const
Definition: TGGC.h:95
EGraphicsFunction GetFunction() const
Definition: TGGC.h:84
Int_t GetJoinStyle() const
Definition: TGGC.h:101
Handle_t Pixmap_t
Definition: GuiTypes.h:31
void SetFillRule(Int_t v)
Set fill rule (kEvenOddRule, kWindingRule).
Definition: TGGC.cxx:354
Int_t fLineWidth
Definition: GuiTypes.h:230
void SetLineWidth(Int_t v)
Set line width.
Definition: TGGC.cxx:298
void SetDashOffset(Int_t v)
Patterned/dashed line offset.
Definition: TGGC.cxx:475
Int_t fSubwindowMode
Definition: GuiTypes.h:244
Bool_t GetGraphicsExposures() const
Definition: TGGC.h:96
Int_t fArcMode
Definition: GuiTypes.h:238
void SetClipMask(Pixmap_t v)
Bitmap for clipping.
Definition: TGGC.cxx:464
void SetSubwindowMode(Int_t v)
Set sub window mode (kClipByChildren, kIncludeInferiors).
Definition: TGGC.cxx:420
Int_t GetClipXOrigin() const
Definition: TGGC.h:97
Definition: TGGC.h:35
EGraphicsFunction
Definition: GuiTypes.h:68
GContext_t operator()() const
Not inline due to a bug in g++ 2.96 20000731 (Red Hat Linux 7.0).
Definition: TGGC.cxx:136
void SetDashList(const char v[], Int_t len)
Set dash pattern. First use SetDashOffset() if not 0.
Definition: TGGC.cxx:486
void SetCapStyle(Int_t v)
Set cap style (kCapNotLast, kCapButt, kCapRound, kCapProjecting).
Definition: TGGC.cxx:320