Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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//////////////////////////////////////////////////////////////////////////
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
28class THashTable;
29
30
31class TGGC : public TObject, public TRefCnt {
32
33friend class TGGCPool;
34
35protected:
36 GCValues_t fValues = {}; // graphics context values + mask
37 GContext_t fContext; // graphics context handle
38
39 TGGC(GCValues_t *values, Bool_t calledByGCPool);
41
42 TString GetMaskString() const; //used in SavePrimitive()
43
44public:
45 TGGC(GCValues_t *values = nullptr);
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);
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);
68 void SetFont(FontH_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; }
86 Pixmap_t GetTile() const { return fValues.fTile; }
87 Pixmap_t GetStipple() const { return fValues.fStipple; }
91 FontH_t GetFont() const { return fValues.fFont; }
96 Int_t GetCapStyle() const { return fValues.fCapStyle; }
99 Int_t GetFillRule() const { return fValues.fFillRule; }
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
112class TGGCPool : public TGObject {
113
114friend class TGGC;
115
116private:
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
123protected:
124 TGGCPool(const TGGCPool& gp) : TGObject(gp), fList(gp.fList) { }
126 {if(this!=&gp) {TGObject::operator=(gp); fList=gp.fList;}
127 return *this;}
128
129public:
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);
140
141 void Print(Option_t *option="") const;
142
143 ClassDef(TGGCPool,0) // Graphics context pool
144};
145
146#endif
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index)
Definition GuiTypes.h:35
EGraphicsFunction
Definition GuiTypes.h:67
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:30
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:38
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:40
#define g(i)
Definition RSha256.hxx:105
int Int_t
Definition RtypesCore.h:45
const Bool_t kFALSE
Definition RtypesCore.h:92
unsigned long ULong_t
Definition RtypesCore.h:55
bool Bool_t
Definition RtypesCore.h:63
const char Option_t
Definition RtypesCore.h:66
#define ClassDef(name, id)
Definition Rtypes.h:325
THashTable * fList
Definition TGGC.h:117
virtual ~TGGCPool()
Delete graphics context pool.
Definition TGGC.cxx:894
Int_t MatchGC(const TGGC *gc, GCValues_t *values)
Try to find matching graphics context.
Definition TGGC.cxx:1038
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get the best matching graphics context depending on values.
Definition TGGC.cxx:986
void FreeGC(const TGGC *gc)
Delete graphics context if it is not used anymore.
Definition TGGC.cxx:917
TGGCPool & operator=(const TGGCPool &gp)
Definition TGGC.h:125
TGGC * FindGC(const TGGC *gc)
Find graphics context. Returns 0 in case gc is not found.
Definition TGGC.cxx:950
void Print(Option_t *option="") const
List all graphics contexts in the pool.
Definition TGGC.cxx:1160
void ForceFreeGC(const TGGC *gc)
Force remove graphics context from list. Is only called via ~TGGC().
Definition TGGC.cxx:902
TGGCPool(const TGGCPool &gp)
Definition TGGC.h:124
void UpdateGC(TGGC *gc, GCValues_t *values)
Update graphics context with the values spcified in values->fMask.
Definition TGGC.cxx:1152
Definition TGGC.h:31
Pixmap_t GetTile() const
Definition TGGC.h:86
void SetArcMode(Int_t v)
Set arc mode (kArcChord, kArcPieSlice).
Definition TGGC.cxx:502
Int_t GetTileStipYOrigin() const
Definition TGGC.h:89
GContext_t GetGC() const
Definition TGGC.h:50
Int_t GetJoinStyle() const
Definition TGGC.h:97
Bool_t GetGraphicsExposures() const
Definition TGGC.h:92
Int_t GetSubwindowMode() const
Definition TGGC.h:90
Int_t GetFillStyle() const
Definition TGGC.h:98
void SavePrimitive(std::ostream &out, Option_t *option="")
Save graphics context info as a C++ statement(s) on output stream out.
Definition TGGC.cxx:626
void SetLineWidth(Int_t v)
Set line width.
Definition TGGC.cxx:299
ULong_t GetPlaneMask() const
Definition TGGC.h:81
Int_t GetDashLen() const
Definition TGGC.h:101
void SetFont(FontH_t v)
Set font.
Definition TGGC.cxx:410
void SetPlaneMask(ULong_t v)
Set plane mask.
Definition TGGC.cxx:266
TGGC & operator=(const TGGC &rhs)
Graphics context assignment operator.
Definition TGGC.cxx:114
GContext_t fContext
Definition TGGC.h:37
void SetTileStipYOrigin(Int_t v)
Y offset for tile or stipple operations.
Definition TGGC.cxx:399
Pixmap_t GetClipMask() const
Definition TGGC.h:95
Int_t GetClipXOrigin() const
Definition TGGC.h:93
FontH_t GetFont() const
Definition TGGC.h:91
void SetFillStyle(Int_t v)
Set fill style (kFillSolid, kFillTiled, kFillStippled, kFillOpaeueStippled).
Definition TGGC.cxx:344
Pixel_t GetForeground() const
Definition TGGC.h:82
Int_t GetFillRule() const
Definition TGGC.h:99
GCValues_t fValues
Definition TGGC.h:36
void SetCapStyle(Int_t v)
Set cap style (kCapNotLast, kCapButt, kCapRound, kCapProjecting).
Definition TGGC.cxx:321
void Print(Option_t *option="") const
Print graphics contexts info.
Definition TGGC.cxx:513
const char * GetDashes() const
Definition TGGC.h:102
Int_t GetTileStipXOrigin() const
Definition TGGC.h:88
void SetForeground(Pixel_t v)
Set foreground color.
Definition TGGC.cxx:277
Int_t GetLineStyle() const
Definition TGGC.h:85
void SetClipMask(Pixmap_t v)
Bitmap for clipping.
Definition TGGC.cxx:465
void SetFillRule(Int_t v)
Set fill rule (kEvenOddRule, kWindingRule).
Definition TGGC.cxx:355
GContext_t operator()() const
Not inline due to a bug in g++ 2.96 20000731 (Red Hat Linux 7.0).
Definition TGGC.cxx:137
void SetDashOffset(Int_t v)
Patterned/dashed line offset.
Definition TGGC.cxx:476
void SetTileStipXOrigin(Int_t v)
X offset for tile or stipple operations.
Definition TGGC.cxx:388
void SetAttributes(GCValues_t *values)
Set attributes as specified in the values structure.
Definition TGGC.cxx:234
void SetDashList(const char v[], Int_t len)
Set dash pattern. First use SetDashOffset() if not 0.
Definition TGGC.cxx:487
EGraphicsFunction GetFunction() const
Definition TGGC.h:80
void SetJoinStyle(Int_t v)
Set line join style (kJoinMiter, kJoinRound, kJoinBevel).
Definition TGGC.cxx:332
void SetClipXOrigin(Int_t v)
X origin for clipping.
Definition TGGC.cxx:443
Int_t GetClipYOrigin() const
Definition TGGC.h:94
Pixel_t GetBackground() const
Definition TGGC.h:83
void SetTile(Pixmap_t v)
Set tile pixmap for tiling operations.
Definition TGGC.cxx:366
void SetClipYOrigin(Int_t v)
Y origin for clipping.
Definition TGGC.cxx:454
void UpdateValues(GCValues_t *v)
Update values + mask.
Definition TGGC.cxx:145
void SetBackground(Pixel_t v)
Set background color.
Definition TGGC.cxx:288
void SetFunction(EGraphicsFunction v)
Set graphics context drawing function.
Definition TGGC.cxx:255
void SetStipple(Pixmap_t v)
Set 1 plane pixmap for stippling.
Definition TGGC.cxx:377
Mask_t GetMask() const
Definition TGGC.h:79
Pixmap_t GetStipple() const
Definition TGGC.h:87
Int_t GetLineWidth() const
Definition TGGC.h:84
void SetGraphicsExposures(Bool_t v)
True if graphics exposure should be generated.
Definition TGGC.cxx:432
void SetLineStyle(Int_t v)
Set line style (kLineSolid, kLineOnOffDash, kLineDoubleDash).
Definition TGGC.cxx:310
Int_t GetDashOffset() const
Definition TGGC.h:100
Int_t GetCapStyle() const
Definition TGGC.h:96
virtual ~TGGC()
Delete graphics context.
Definition TGGC.cxx:102
const GCValues_t * GetAttributes() const
Definition TGGC.h:78
Int_t GetArcMode() const
Definition TGGC.h:103
TString GetMaskString() const
Returns GC mask as a string - used in SavePrimitive().
Definition TGGC.cxx:522
void SetSubwindowMode(Int_t v)
Set sub window mode (kClipByChildren, kIncludeInferiors).
Definition TGGC.cxx:421
TGObject & operator=(const TGObject &tgo)
Definition TGObject.h:39
THashTable implements a hash table to store TObject's.
Definition THashTable.h:35
Mother of all ROOT objects.
Definition TObject.h:37
Definitions for TRefCnt, base class for reference counted objects.
Definition TRefCnt.h:27
Basic string class.
Definition TString.h:136
Graphics context structure.
Definition GuiTypes.h:224
ULong_t fBackground
background pixel
Definition GuiTypes.h:228
Int_t fFillRule
kEvenOddRule, kWindingRule
Definition GuiTypes.h:236
Pixmap_t fClipMask
bitmap clipping; other calls for rects
Definition GuiTypes.h:247
Int_t fDashOffset
patterned/dashed line information
Definition GuiTypes.h:248
Int_t fClipYOrigin
Definition GuiTypes.h:246
Int_t fClipXOrigin
origin for clipping
Definition GuiTypes.h:245
Int_t fLineWidth
line width
Definition GuiTypes.h:229
Pixmap_t fStipple
stipple 1 plane pixmap for stippling
Definition GuiTypes.h:239
Mask_t fMask
bit mask specifying which fields are valid
Definition GuiTypes.h:251
Int_t fLineStyle
kLineSolid, kLineOnOffDash, kLineDoubleDash
Definition GuiTypes.h:230
Pixmap_t fTile
tile pixmap for tiling operations
Definition GuiTypes.h:238
Bool_t fGraphicsExposures
boolean, should exposures be generated
Definition GuiTypes.h:244
Int_t fJoinStyle
kJoinMiter, kJoinRound, kJoinBevel
Definition GuiTypes.h:233
Char_t fDashes[8]
dash pattern list (dash length per byte)
Definition GuiTypes.h:249
ULong_t fForeground
foreground pixel
Definition GuiTypes.h:227
ULong_t fPlaneMask
plane mask
Definition GuiTypes.h:226
Int_t fFillStyle
kFillSolid, kFillTiled, kFillStippled, kFillOpaeueStippled
Definition GuiTypes.h:234
FontH_t fFont
default text font for text operations
Definition GuiTypes.h:242
Int_t fTsXOrigin
offset for tile or stipple operations
Definition GuiTypes.h:240
EGraphicsFunction fFunction
logical operation
Definition GuiTypes.h:225
Int_t fDashLen
number of dashes in fDashes
Definition GuiTypes.h:250
Int_t fCapStyle
kCapNotLast, kCapButt, kCapRound, kCapProjecting
Definition GuiTypes.h:231
Int_t fArcMode
kArcChord, kArcPieSlice
Definition GuiTypes.h:237
Int_t fTsYOrigin
Definition GuiTypes.h:241
Int_t fSubwindowMode
kClipByChildren, kIncludeInferiors
Definition GuiTypes.h:243