Logo ROOT   6.10/09
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 #include "TGObject.h"
26 #include "TRefCnt.h"
27 
28 class THashTable;
29 
30 
31 class TGGC : public TObject, public TRefCnt {
32 
33 friend class TGGCPool;
34 
35 protected:
36  GCValues_t fValues; // graphics context values + mask
37  GContext_t fContext; // graphics context handle
38 
39  TGGC(GCValues_t *values, Bool_t calledByGCPool);
40  void UpdateValues(GCValues_t *v);
41 
42  TString GetMaskString() const; //used in SavePrimitive()
43 
44 public:
45  TGGC(GCValues_t *values = 0);
46  TGGC(const TGGC &g);
47  virtual ~TGGC();
48  TGGC &operator=(const TGGC &rhs);
49 
50  GContext_t GetGC() const { return fContext; }
51  GContext_t operator()() const;
52 
53  void SetAttributes(GCValues_t *values);
55  void SetPlaneMask(ULong_t v);
56  void SetForeground(Pixel_t v);
57  void SetBackground(Pixel_t v);
58  void SetLineWidth(Int_t v);
59  void SetLineStyle(Int_t v);
60  void SetCapStyle(Int_t v);
61  void SetJoinStyle(Int_t v);
62  void SetFillStyle(Int_t v);
63  void SetFillRule(Int_t v);
64  void SetTile(Pixmap_t v);
65  void SetStipple(Pixmap_t v);
66  void SetTileStipXOrigin(Int_t v);
67  void SetTileStipYOrigin(Int_t v);
68  void SetFont(FontH_t v);
69  void SetSubwindowMode(Int_t v);
71  void SetClipXOrigin(Int_t v);
72  void SetClipYOrigin(Int_t v);
73  void SetClipMask(Pixmap_t v);
74  void SetDashOffset(Int_t v);
75  void SetDashList(const char v[], Int_t len);
76  void SetArcMode(Int_t v);
77 
78  const GCValues_t *GetAttributes() const { return &fValues; }
79  Mask_t GetMask() const { return fValues.fMask; }
80  EGraphicsFunction GetFunction() const { return fValues.fFunction; }
81  ULong_t GetPlaneMask() const { return fValues.fPlaneMask; }
82  Pixel_t GetForeground() const { return fValues.fForeground; }
83  Pixel_t GetBackground() const { return fValues.fBackground; }
84  Int_t GetLineWidth() const { return fValues.fLineWidth; }
85  Int_t GetLineStyle() const { return fValues.fLineStyle; }
86  Pixmap_t GetTile() const { return fValues.fTile; }
87  Pixmap_t GetStipple() const { return fValues.fStipple; }
88  Int_t GetTileStipXOrigin() const { return fValues.fTsXOrigin; }
89  Int_t GetTileStipYOrigin() const { return fValues.fTsYOrigin; }
90  Int_t GetSubwindowMode() const { return fValues.fSubwindowMode; }
91  FontH_t GetFont() const { return fValues.fFont; }
92  Bool_t GetGraphicsExposures() const { return fValues.fGraphicsExposures; }
93  Int_t GetClipXOrigin() const { return fValues.fClipXOrigin; }
94  Int_t GetClipYOrigin() const { return fValues.fClipYOrigin; }
95  Pixmap_t GetClipMask() const { return fValues.fClipMask; }
96  Int_t GetCapStyle() const { return fValues.fCapStyle; }
97  Int_t GetJoinStyle() const { return fValues.fJoinStyle; }
98  Int_t GetFillStyle() const { return fValues.fFillStyle; }
99  Int_t GetFillRule() const { return fValues.fFillRule; }
100  Int_t GetDashOffset() const { return fValues.fDashOffset; }
101  Int_t GetDashLen() const { return fValues.fDashLen; }
102  const char *GetDashes() const { return fValues.fDashes; }
103  Int_t GetArcMode() const { return fValues.fArcMode; }
104 
105  void Print(Option_t *option="") const;
106  void SavePrimitive(std::ostream &out, Option_t *option = "");
107 
108  ClassDef(TGGC,0) // Graphics context
109 };
110 
111 
112 class TGGCPool : public TGObject {
113 
114 friend class TGGC;
115 
116 private:
117  THashTable *fList; // hash table of graphics contexts in pool
118 
119  void ForceFreeGC(const TGGC *gc);
120  Int_t MatchGC(const TGGC *gc, GCValues_t *values);
121  void UpdateGC(TGGC *gc, GCValues_t *values);
122 
123 protected:
124  TGGCPool(const TGGCPool& gp) : TGObject(gp), fList(gp.fList) { }
126  {if(this!=&gp) {TGObject::operator=(gp); fList=gp.fList;}
127  return *this;}
128 
129 public:
130  TGGCPool(TGClient *client);
131  virtual ~TGGCPool();
132 
133  TGGC *GetGC(GCValues_t *values, Bool_t rw = kFALSE);
134  TGGC *GetGC(GContext_t gct);
135  void FreeGC(const TGGC *gc);
136  void FreeGC(GContext_t gc);
137 
138  TGGC *FindGC(const TGGC *gc);
139  TGGC *FindGC(GContext_t gc);
140 
141  void Print(Option_t *option="") const;
142 
143  ClassDef(TGGCPool,0) // Graphics context pool
144 };
145 
146 #endif
Int_t GetLineWidth() const
Definition: TGGC.h:84
Int_t fClipXOrigin
Definition: GuiTypes.h:244
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:229
Int_t GetClipYOrigin() const
Definition: TGGC.h:94
Char_t fDashes[8]
Definition: GuiTypes.h:248
void SetPlaneMask(ULong_t v)
Set plane mask.
Definition: TGGC.cxx:265
Pixmap_t fTile
Definition: GuiTypes.h:237
Int_t GetDashLen() const
Definition: TGGC.h:101
void SetTileStipYOrigin(Int_t v)
Y offset for tile or stipple operations.
Definition: TGGC.cxx:398
Int_t GetDashOffset() const
Definition: TGGC.h:100
void UpdateValues(GCValues_t *v)
Update values + mask.
Definition: TGGC.cxx:144
Int_t GetCapStyle() const
Definition: TGGC.h:96
FontH_t fFont
Definition: GuiTypes.h:241
UInt_t Mask_t
Definition: GuiTypes.h:40
const char Option_t
Definition: RtypesCore.h:62
Pixmap_t GetStipple() const
Definition: TGGC.h:87
Pixel_t GetBackground() const
Definition: TGGC.h:83
void SetForeground(Pixel_t v)
Set foreground color.
Definition: TGGC.cxx:276
Int_t GetTileStipXOrigin() const
Definition: TGGC.h:88
Definitions for TRefCnt, base class for reference counted objects.
Definition: TRefCnt.h:27
Int_t fTsYOrigin
Definition: GuiTypes.h:240
Handle_t GContext_t
Definition: GuiTypes.h:37
ULong_t fPlaneMask
Definition: GuiTypes.h:225
Basic string class.
Definition: TString.h:129
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
ULong_t GetPlaneMask() const
Definition: TGGC.h:81
Int_t fClipYOrigin
Definition: GuiTypes.h:245
Int_t fFillStyle
Definition: GuiTypes.h:233
Pixmap_t fClipMask
Definition: GuiTypes.h:246
TGGC & operator=(const TGGC &rhs)
Graphics context assignment operator.
Definition: TGGC.cxx:113
EGraphicsFunction fFunction
Definition: GuiTypes.h:224
GCValues_t fValues
Definition: TGGC.h:36
void SetFunction(EGraphicsFunction v)
Set graphics context drawing function.
Definition: TGGC.cxx:254
Handle_t FontH_t
Definition: GuiTypes.h:34
GContext_t fContext
Definition: TGGC.h:37
Definition: TGGC.h:112
TGGCPool(const TGGCPool &gp)
Definition: TGGC.h:124
void SetBackground(Pixel_t v)
Set background color.
Definition: TGGC.cxx:287
THashTable implements a hash table to store TObject's.
Definition: THashTable.h:35
#define ClassDef(name, id)
Definition: Rtypes.h:297
ULong_t Pixel_t
Definition: GuiTypes.h:39
Int_t fDashOffset
Definition: GuiTypes.h:247
ULong_t fForeground
Definition: GuiTypes.h:226
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:98
Pixmap_t GetClipMask() const
Definition: TGGC.h:95
Int_t GetTileStipYOrigin() const
Definition: TGGC.h:89
const GCValues_t * GetAttributes() const
Definition: TGGC.h:78
void SetStipple(Pixmap_t v)
Set 1 plane pixmap for stippling.
Definition: TGGC.cxx:376
Int_t fTsXOrigin
Definition: GuiTypes.h:239
TGGCPool & operator=(const TGGCPool &gp)
Definition: TGGC.h:125
Mask_t GetMask() const
Definition: TGGC.h:79
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:243
void SetTileStipXOrigin(Int_t v)
X offset for tile or stipple operations.
Definition: TGGC.cxx:387
Int_t fDashLen
Definition: GuiTypes.h:249
void SetTile(Pixmap_t v)
Set tile pixmap for tiling operations.
Definition: TGGC.cxx:365
Pixel_t GetForeground() const
Definition: TGGC.h:82
SVector< double, 2 > v
Definition: Dict.h:5
friend class TGGCPool
Definition: TGGC.h:33
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:99
Pixmap_t fStipple
Definition: GuiTypes.h:238
const Bool_t kFALSE
Definition: RtypesCore.h:92
THashTable * fList
Definition: TGGC.h:117
ULong_t fBackground
Definition: GuiTypes.h:227
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:102
GContext_t GetGC() const
Definition: TGGC.h:50
unsigned long ULong_t
Definition: RtypesCore.h:51
Int_t fJoinStyle
Definition: GuiTypes.h:232
TString GetMaskString() const
Returns GC mask as a string - used in SavePrimitive().
Definition: TGGC.cxx:521
TGObject & operator=(const TGObject &tgo)
Definition: TGObject.h:39
Pixmap_t GetTile() const
Definition: TGGC.h:86
Int_t GetSubwindowMode() const
Definition: TGGC.h:90
Int_t fCapStyle
Definition: GuiTypes.h:230
Int_t GetLineStyle() const
Definition: TGGC.h:85
Int_t GetArcMode() const
Definition: TGGC.h:103
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:235
Mask_t fMask
Definition: GuiTypes.h:250
FontH_t GetFont() const
Definition: TGGC.h:91
EGraphicsFunction GetFunction() const
Definition: TGGC.h:80
Int_t GetJoinStyle() const
Definition: TGGC.h:97
Handle_t Pixmap_t
Definition: GuiTypes.h:29
void SetFillRule(Int_t v)
Set fill rule (kEvenOddRule, kWindingRule).
Definition: TGGC.cxx:354
Int_t fLineWidth
Definition: GuiTypes.h:228
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:242
Bool_t GetGraphicsExposures() const
Definition: TGGC.h:92
Int_t fArcMode
Definition: GuiTypes.h:236
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:93
Definition: TGGC.h:31
EGraphicsFunction
Definition: GuiTypes.h:66
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