Logo ROOT  
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-2021, 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 #include "TGObject.h"
17 #include "TRefCnt.h"
18 
19 class THashTable;
20 
21 
22 class TGGC : public TObject, public TRefCnt {
23 
24 friend class TGGCPool;
25 
26 protected:
27  GCValues_t fValues = {}; ///< graphics context values + mask
28  GContext_t fContext; ///< graphics context handle
29 
30  TGGC(GCValues_t *values, Bool_t calledByGCPool);
31  void UpdateValues(GCValues_t *v);
32 
33  TString GetMaskString() const; //used in SavePrimitive()
34 
35 public:
36  TGGC(GCValues_t *values = nullptr);
37  TGGC(const TGGC &g);
38  virtual ~TGGC();
39  TGGC &operator=(const TGGC &rhs);
40 
41  GContext_t GetGC() const { return fContext; }
42  GContext_t operator()() const;
43 
44  void SetAttributes(GCValues_t *values);
46  void SetPlaneMask(ULong_t v);
47  void SetForeground(Pixel_t v);
48  void SetBackground(Pixel_t v);
49  void SetLineWidth(Int_t v);
50  void SetLineStyle(Int_t v);
51  void SetCapStyle(Int_t v);
52  void SetJoinStyle(Int_t v);
53  void SetFillStyle(Int_t v);
54  void SetFillRule(Int_t v);
55  void SetTile(Pixmap_t v);
56  void SetStipple(Pixmap_t v);
59  void SetFont(FontH_t v);
60  void SetSubwindowMode(Int_t v);
62  void SetClipXOrigin(Int_t v);
63  void SetClipYOrigin(Int_t v);
64  void SetClipMask(Pixmap_t v);
65  void SetDashOffset(Int_t v);
66  void SetDashList(const char v[], Int_t len);
67  void SetArcMode(Int_t v);
68 
69  const GCValues_t *GetAttributes() const { return &fValues; }
70  Mask_t GetMask() const { return fValues.fMask; }
72  ULong_t GetPlaneMask() const { return fValues.fPlaneMask; }
75  Int_t GetLineWidth() const { return fValues.fLineWidth; }
76  Int_t GetLineStyle() const { return fValues.fLineStyle; }
77  Pixmap_t GetTile() const { return fValues.fTile; }
78  Pixmap_t GetStipple() const { return fValues.fStipple; }
82  FontH_t GetFont() const { return fValues.fFont; }
86  Pixmap_t GetClipMask() const { return fValues.fClipMask; }
87  Int_t GetCapStyle() const { return fValues.fCapStyle; }
88  Int_t GetJoinStyle() const { return fValues.fJoinStyle; }
89  Int_t GetFillStyle() const { return fValues.fFillStyle; }
90  Int_t GetFillRule() const { return fValues.fFillRule; }
91  Int_t GetDashOffset() const { return fValues.fDashOffset; }
92  Int_t GetDashLen() const { return fValues.fDashLen; }
93  const char *GetDashes() const { return fValues.fDashes; }
94  Int_t GetArcMode() const { return fValues.fArcMode; }
95 
96  void Print(Option_t *option="") const;
97  void SavePrimitive(std::ostream &out, Option_t *option = "");
98 
99  ClassDef(TGGC,0) // Graphics context
100 };
101 
102 
103 class TGGCPool : public TGObject {
104 
105 friend class TGGC;
106 
107 private:
108  THashTable *fList; // hash table of graphics contexts in pool
109 
110  void ForceFreeGC(const TGGC *gc);
111  Int_t MatchGC(const TGGC *gc, GCValues_t *values);
112  void UpdateGC(TGGC *gc, GCValues_t *values);
113 
114 protected:
115  TGGCPool(const TGGCPool& gp) : TGObject(gp), fList(gp.fList) { }
117  {if(this!=&gp) {TGObject::operator=(gp); fList=gp.fList;}
118  return *this;}
119 
120 public:
121  TGGCPool(TGClient *client);
122  virtual ~TGGCPool();
123 
124  TGGC *GetGC(GCValues_t *values, Bool_t rw = kFALSE);
125  TGGC *GetGC(GContext_t gct);
126  void FreeGC(const TGGC *gc);
127  void FreeGC(GContext_t gc);
128 
129  TGGC *FindGC(const TGGC *gc);
130  TGGC *FindGC(GContext_t gc);
131 
132  void Print(Option_t *option="") const;
133 
134  ClassDef(TGGCPool,0) // Graphics context pool
135 };
136 
137 #endif
TGObject
This class is the baseclass for all ROOT GUI widgets.
Definition: TGObject.h:22
TGGCPool::fList
THashTable * fList
Definition: TGGC.h:108
GCValues_t::fJoinStyle
Int_t fJoinStyle
kJoinMiter, kJoinRound, kJoinBevel
Definition: GuiTypes.h:233
Pixmap_t
Handle_t Pixmap_t
Pixmap handle.
Definition: GuiTypes.h:30
TGGC::Print
void Print(Option_t *option="") const
Print graphics contexts info.
Definition: TGGC.cxx:514
TGGC::GetDashes
const char * GetDashes() const
Definition: TGGC.h:93
TGGCPool::~TGGCPool
virtual ~TGGCPool()
Delete graphics context pool.
Definition: TGGC.cxx:895
TGGC::SetLineStyle
void SetLineStyle(Int_t v)
Set line style (kLineSolid, kLineOnOffDash, kLineDoubleDash).
Definition: TGGC.cxx:311
TGGC::GetTileStipYOrigin
Int_t GetTileStipYOrigin() const
Definition: TGGC.h:80
TGGC::GetGC
GContext_t GetGC() const
Definition: TGGC.h:41
TGGCPool::Print
void Print(Option_t *option="") const
List all graphics contexts in the pool.
Definition: TGGC.cxx:1161
TGGC::GetForeground
Pixel_t GetForeground() const
Definition: TGGC.h:73
TGGC::GetAttributes
const GCValues_t * GetAttributes() const
Definition: TGGC.h:69
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGGC::GetSubwindowMode
Int_t GetSubwindowMode() const
Definition: TGGC.h:81
TGGC::SetJoinStyle
void SetJoinStyle(Int_t v)
Set line join style (kJoinMiter, kJoinRound, kJoinBevel).
Definition: TGGC.cxx:333
TGGC::SetClipYOrigin
void SetClipYOrigin(Int_t v)
Y origin for clipping.
Definition: TGGC.cxx:455
Pixel_t
ULong_t Pixel_t
Pixel value.
Definition: GuiTypes.h:40
TGGC::SetClipXOrigin
void SetClipXOrigin(Int_t v)
X origin for clipping.
Definition: TGGC.cxx:444
GCValues_t::fStipple
Pixmap_t fStipple
stipple 1 plane pixmap for stippling
Definition: GuiTypes.h:239
FontH_t
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Definition: GuiTypes.h:35
TGGC::SetTileStipXOrigin
void SetTileStipXOrigin(Int_t v)
X offset for tile or stipple operations.
Definition: TGGC.cxx:389
TGGC::SavePrimitive
void SavePrimitive(std::ostream &out, Option_t *option="")
Save graphics context info as a C++ statement(s) on output stream out.
Definition: TGGC.cxx:627
GCValues_t::fClipXOrigin
Int_t fClipXOrigin
origin for clipping
Definition: GuiTypes.h:245
TGGC::GetFont
FontH_t GetFont() const
Definition: TGGC.h:82
TGGC::GetMaskString
TString GetMaskString() const
Returns GC mask as a string - used in SavePrimitive().
Definition: TGGC.cxx:523
GCValues_t
Graphics context structure.
Definition: GuiTypes.h:224
TRefCnt.h
TGGC::SetFillRule
void SetFillRule(Int_t v)
Set fill rule (kEvenOddRule, kWindingRule).
Definition: TGGC.cxx:356
TGGC::SetFillStyle
void SetFillStyle(Int_t v)
Set fill style (kFillSolid, kFillTiled, kFillStippled, kFillOpaeueStippled).
Definition: TGGC.cxx:345
TGGC::SetAttributes
void SetAttributes(GCValues_t *values)
Set attributes as specified in the values structure.
Definition: TGGC.cxx:235
GCValues_t::fDashes
Char_t fDashes[8]
dash pattern list (dash length per byte)
Definition: GuiTypes.h:249
TGGC::SetGraphicsExposures
void SetGraphicsExposures(Bool_t v)
True if graphics exposure should be generated.
Definition: TGGC.cxx:433
Int_t
int Int_t
Definition: RtypesCore.h:45
GCValues_t::fFillStyle
Int_t fFillStyle
kFillSolid, kFillTiled, kFillStippled, kFillOpaeueStippled
Definition: GuiTypes.h:234
GCValues_t::fTsXOrigin
Int_t fTsXOrigin
offset for tile or stipple operations
Definition: GuiTypes.h:240
TGGC::GetJoinStyle
Int_t GetJoinStyle() const
Definition: TGGC.h:88
TGGC::GetFillRule
Int_t GetFillRule() const
Definition: TGGC.h:90
TGGC::GetTile
Pixmap_t GetTile() const
Definition: TGGC.h:77
TGObject.h
TGGC::SetLineWidth
void SetLineWidth(Int_t v)
Set line width.
Definition: TGGC.cxx:300
GCValues_t::fFillRule
Int_t fFillRule
kEvenOddRule, kWindingRule
Definition: GuiTypes.h:236
TString
Basic string class.
Definition: TString.h:136
TGGC::SetDashOffset
void SetDashOffset(Int_t v)
Patterned/dashed line offset.
Definition: TGGC.cxx:477
TGGC::GetArcMode
Int_t GetArcMode() const
Definition: TGGC.h:94
Bool_t
bool Bool_t
Definition: RtypesCore.h:63
v
@ v
Definition: rootcling_impl.cxx:3664
GCValues_t::fPlaneMask
ULong_t fPlaneMask
plane mask
Definition: GuiTypes.h:226
TGGCPool::GetGC
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get the best matching graphics context depending on values.
Definition: TGGC.cxx:987
TGGC::GetGraphicsExposures
Bool_t GetGraphicsExposures() const
Definition: TGGC.h:83
bool
TGGCPool::FreeGC
void FreeGC(const TGGC *gc)
Delete graphics context if it is not used anymore.
Definition: TGGC.cxx:918
TGGC::GetClipYOrigin
Int_t GetClipYOrigin() const
Definition: TGGC.h:85
GCValues_t::fTsYOrigin
Int_t fTsYOrigin
Definition: GuiTypes.h:241
GContext_t
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
TGGC::operator()
GContext_t operator()() const
Not inline due to a bug in g++ 2.96 20000731 (Red Hat Linux 7.0).
Definition: TGGC.cxx:138
TGGC::GetDashLen
Int_t GetDashLen() const
Definition: TGGC.h:92
TGGC::GetLineStyle
Int_t GetLineStyle() const
Definition: TGGC.h:76
GCValues_t::fSubwindowMode
Int_t fSubwindowMode
kClipByChildren, kIncludeInferiors
Definition: GuiTypes.h:243
TGGC::SetCapStyle
void SetCapStyle(Int_t v)
Set cap style (kCapNotLast, kCapButt, kCapRound, kCapProjecting).
Definition: TGGC.cxx:322
TGGC::TGGC
TGGC(GCValues_t *values, Bool_t calledByGCPool)
Create a graphics context (only called via TGGCPool::GetGC()).
Definition: TGGC.cxx:38
TGGC::GetLineWidth
Int_t GetLineWidth() const
Definition: TGGC.h:75
TGGCPool::operator=
TGGCPool & operator=(const TGGCPool &gp)
Definition: TGGC.h:116
GCValues_t::fArcMode
Int_t fArcMode
kArcChord, kArcPieSlice
Definition: GuiTypes.h:237
TGGC::GetFunction
EGraphicsFunction GetFunction() const
Definition: TGGC.h:71
TGGC::GetClipXOrigin
Int_t GetClipXOrigin() const
Definition: TGGC.h:84
TGObject::operator=
TGObject & operator=(const TGObject &tgo)
Definition: TGObject.h:29
THashTable
THashTable implements a hash table to store TObject's.
Definition: THashTable.h:35
TGGC::SetTileStipYOrigin
void SetTileStipYOrigin(Int_t v)
Y offset for tile or stipple operations.
Definition: TGGC.cxx:400
TGGC
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
TGGC::GetDashOffset
Int_t GetDashOffset() const
Definition: TGGC.h:91
kFALSE
const Bool_t kFALSE
Definition: RtypesCore.h:101
GCValues_t::fLineStyle
Int_t fLineStyle
kLineSolid, kLineOnOffDash, kLineDoubleDash
Definition: GuiTypes.h:230
GCValues_t::fFont
FontH_t fFont
default text font for text operations
Definition: GuiTypes.h:242
TGGC::GetStipple
Pixmap_t GetStipple() const
Definition: TGGC.h:78
TGGC::SetClipMask
void SetClipMask(Pixmap_t v)
Bitmap for clipping.
Definition: TGGC.cxx:466
TGGC::SetSubwindowMode
void SetSubwindowMode(Int_t v)
Set sub window mode (kClipByChildren, kIncludeInferiors).
Definition: TGGC.cxx:422
GCValues_t::fBackground
ULong_t fBackground
background pixel
Definition: GuiTypes.h:228
GCValues_t::fDashOffset
Int_t fDashOffset
patterned/dashed line information
Definition: GuiTypes.h:248
TGGCPool::UpdateGC
void UpdateGC(TGGC *gc, GCValues_t *values)
Update graphics context with the values spcified in values->fMask.
Definition: TGGC.cxx:1153
ULong_t
unsigned long ULong_t
Definition: RtypesCore.h:55
TGGC::SetDashList
void SetDashList(const char v[], Int_t len)
Set dash pattern. First use SetDashOffset() if not 0.
Definition: TGGC.cxx:488
TGGC::UpdateValues
void UpdateValues(GCValues_t *v)
Update values + mask.
Definition: TGGC.cxx:146
GCValues_t::fGraphicsExposures
Bool_t fGraphicsExposures
boolean, should exposures be generated
Definition: GuiTypes.h:244
TGGCPool::ForceFreeGC
void ForceFreeGC(const TGGC *gc)
Force remove graphics context from list. Is only called via ~TGGC().
Definition: TGGC.cxx:903
TGGC::GetCapStyle
Int_t GetCapStyle() const
Definition: TGGC.h:87
GCValues_t::fClipYOrigin
Int_t fClipYOrigin
Definition: GuiTypes.h:246
TGGC::fContext
GContext_t fContext
graphics context handle
Definition: TGGC.h:28
unsigned int
GCValues_t::fTile
Pixmap_t fTile
tile pixmap for tiling operations
Definition: GuiTypes.h:238
TGGC::SetPlaneMask
void SetPlaneMask(ULong_t v)
Set plane mask.
Definition: TGGC.cxx:267
TGGC::fValues
GCValues_t fValues
graphics context values + mask
Definition: TGGC.h:27
TGGC::SetArcMode
void SetArcMode(Int_t v)
Set arc mode (kArcChord, kArcPieSlice).
Definition: TGGC.cxx:503
EGraphicsFunction
EGraphicsFunction
Definition: GuiTypes.h:67
TGGC::GetBackground
Pixel_t GetBackground() const
Definition: TGGC.h:74
TGGC::GetPlaneMask
ULong_t GetPlaneMask() const
Definition: TGGC.h:72
GCValues_t::fMask
Mask_t fMask
bit mask specifying which fields are valid
Definition: GuiTypes.h:251
TGGCPool
Definition: TGGC.h:103
TGGC::SetBackground
void SetBackground(Pixel_t v)
Set background color.
Definition: TGGC.cxx:289
TGGC::SetForeground
void SetForeground(Pixel_t v)
Set foreground color.
Definition: TGGC.cxx:278
GCValues_t::fClipMask
Pixmap_t fClipMask
bitmap clipping; other calls for rects
Definition: GuiTypes.h:247
GCValues_t::fDashLen
Int_t fDashLen
number of dashes in fDashes
Definition: GuiTypes.h:250
TGGC::GetTileStipXOrigin
Int_t GetTileStipXOrigin() const
Definition: TGGC.h:79
TObject
Mother of all ROOT objects.
Definition: TObject.h:37
TGGC::GetClipMask
Pixmap_t GetClipMask() const
Definition: TGGC.h:86
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TGGC::operator=
TGGC & operator=(const TGGC &rhs)
Graphics context assignment operator.
Definition: TGGC.cxx:115
GCValues_t::fFunction
EGraphicsFunction fFunction
logical operation
Definition: GuiTypes.h:225
GCValues_t::fForeground
ULong_t fForeground
foreground pixel
Definition: GuiTypes.h:227
TRefCnt
Definitions for TRefCnt, base class for reference counted objects.
Definition: TRefCnt.h:27
TGGC::GetMask
Mask_t GetMask() const
Definition: TGGC.h:70
TGGCPool::FindGC
TGGC * FindGC(const TGGC *gc)
Find graphics context. Returns 0 in case gc is not found.
Definition: TGGC.cxx:951
TGGCPool::MatchGC
Int_t MatchGC(const TGGC *gc, GCValues_t *values)
Try to find matching graphics context.
Definition: TGGC.cxx:1039
TGGC::SetFunction
void SetFunction(EGraphicsFunction v)
Set graphics context drawing function.
Definition: TGGC.cxx:256
TGGCPool::TGGCPool
TGGCPool(const TGGCPool &gp)
Definition: TGGC.h:115
TGGC::SetFont
void SetFont(FontH_t v)
Set font.
Definition: TGGC.cxx:411
TGClient
Window client.
Definition: TGClient.h:37
TGGC::~TGGC
virtual ~TGGC()
Delete graphics context.
Definition: TGGC.cxx:103
TGGC::SetTile
void SetTile(Pixmap_t v)
Set tile pixmap for tiling operations.
Definition: TGGC.cxx:367
TGGC::GetFillStyle
Int_t GetFillStyle() const
Definition: TGGC.h:89
GCValues_t::fLineWidth
Int_t fLineWidth
line width
Definition: GuiTypes.h:229
int
GCValues_t::fCapStyle
Int_t fCapStyle
kCapNotLast, kCapButt, kCapRound, kCapProjecting
Definition: GuiTypes.h:231
TGGC::SetStipple
void SetStipple(Pixmap_t v)
Set 1 plane pixmap for stippling.
Definition: TGGC.cxx:378
g
#define g(i)
Definition: RSha256.hxx:105