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#include "TGObject.h"
17#include "TRefCnt.h"
18
19class THashTable;
20
21
22class TGGC : public TObject, public TRefCnt {
23
24friend class TGGCPool;
25
26protected:
27 GCValues_t fValues = {}; ///< graphics context values + mask
28 GContext_t fContext; ///< graphics context handle
29
30 TGGC(GCValues_t *values, Bool_t calledByGCPool);
32
33 TString GetMaskString() const; //used in SavePrimitive()
34
35public:
36 TGGC(GCValues_t *values = nullptr);
37 TGGC(const TGGC &g);
38 ~TGGC() override;
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);
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);
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; }
71 EGraphicsFunction GetFunction() const { return fValues.fFunction; }
72 ULong_t GetPlaneMask() const { return fValues.fPlaneMask; }
73 Pixel_t GetForeground() const { return fValues.fForeground; }
74 Pixel_t GetBackground() const { return fValues.fBackground; }
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; }
79 Int_t GetTileStipXOrigin() const { return fValues.fTsXOrigin; }
80 Int_t GetTileStipYOrigin() const { return fValues.fTsYOrigin; }
81 Int_t GetSubwindowMode() const { return fValues.fSubwindowMode; }
82 FontH_t GetFont() const { return fValues.fFont; }
83 Bool_t GetGraphicsExposures() const { return fValues.fGraphicsExposures; }
84 Int_t GetClipXOrigin() const { return fValues.fClipXOrigin; }
85 Int_t GetClipYOrigin() const { return fValues.fClipYOrigin; }
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 override;
97 void SavePrimitive(std::ostream &out, Option_t *option = "") override;
98
99 ClassDefOverride(TGGC,0) // Graphics context
100};
101
102
103class TGGCPool : public TGObject {
104
105friend class TGGC;
106
107private:
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
114protected:
115 TGGCPool(const TGGCPool& gp) : TGObject(gp), fList(gp.fList) { }
117 {
118 if (this != &gp) {
120 fList = gp.fList;
121 }
122 return *this;
123 }
124
125public:
126 TGGCPool(TGClient *client);
127 ~TGGCPool() override;
128
129 TGGC *GetGC(GCValues_t *values, Bool_t rw = kFALSE);
130 TGGC *GetGC(GContext_t gct);
131 void FreeGC(const TGGC *gc);
132 void FreeGC(GContext_t gc);
133
134 TGGC *FindGC(const TGGC *gc);
136
137 void Print(Option_t *option="") const override;
138
139 ClassDefOverride(TGGCPool,0) // Graphics context pool
140};
141
142#endif
Handle_t FontH_t
Font handle (as opposed to Font_t which is an index).
Definition GuiTypes.h:36
EGraphicsFunction
Definition GuiTypes.h:68
Handle_t Pixmap_t
Pixmap handle.
Definition GuiTypes.h:31
Handle_t GContext_t
Graphics context handle.
Definition GuiTypes.h:39
UInt_t Mask_t
Structure mask type.
Definition GuiTypes.h:42
ULong_t Pixel_t
Pixel value.
Definition GuiTypes.h:41
#define g(i)
Definition RSha256.hxx:105
int Int_t
Signed integer 4 bytes (int).
Definition RtypesCore.h:59
unsigned long ULong_t
Unsigned long integer 4 bytes (unsigned long). Size depends on architecture.
Definition RtypesCore.h:69
bool Bool_t
Boolean (0=false, 1=true) (bool).
Definition RtypesCore.h:77
constexpr Bool_t kFALSE
Definition RtypesCore.h:108
const char Option_t
Option string (const char).
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
Window client.
Definition TGClient.h:37
THashTable * fList
Definition TGGC.h:108
void Print(Option_t *option="") const override
List all graphics contexts in the pool.
Definition TGGC.cxx:1143
Int_t MatchGC(const TGGC *gc, GCValues_t *values)
Try to find matching graphics context.
Definition TGGC.cxx:1021
~TGGCPool() override
Delete graphics context pool.
Definition TGGC.cxx:877
TGGC * GetGC(GCValues_t *values, Bool_t rw=kFALSE)
Get the best matching graphics context depending on values.
Definition TGGC.cxx:969
void FreeGC(const TGGC *gc)
Delete graphics context if it is not used anymore.
Definition TGGC.cxx:900
TGGCPool & operator=(const TGGCPool &gp)
Definition TGGC.h:116
friend class TGGC
Definition TGGC.h:105
TGGC * FindGC(const TGGC *gc)
Find graphics context. Returns 0 in case gc is not found.
Definition TGGC.cxx:933
void ForceFreeGC(const TGGC *gc)
Force remove graphics context from list. Is only called via ~TGGC().
Definition TGGC.cxx:885
TGGCPool(const TGGCPool &gp)
Definition TGGC.h:115
void UpdateGC(TGGC *gc, GCValues_t *values)
Update graphics context with the values spcified in values->fMask.
Definition TGGC.cxx:1135
Encapsulate a graphics context used in the low level graphics.
Definition TGGC.h:22
Pixmap_t GetTile() const
Definition TGGC.h:77
void SetArcMode(Int_t v)
Set arc mode (kArcChord, kArcPieSlice).
Definition TGGC.cxx:495
Int_t GetTileStipYOrigin() const
Definition TGGC.h:80
GContext_t GetGC() const
Definition TGGC.h:41
TGGC(GCValues_t *values, Bool_t calledByGCPool)
Create a graphics context (only called via TGGCPool::GetGC()).
Definition TGGC.cxx:37
Int_t GetJoinStyle() const
Definition TGGC.h:88
Bool_t GetGraphicsExposures() const
Definition TGGC.h:83
Int_t GetSubwindowMode() const
Definition TGGC.h:81
Int_t GetFillStyle() const
Definition TGGC.h:89
void SetLineWidth(Int_t v)
Set line width.
Definition TGGC.cxx:292
ULong_t GetPlaneMask() const
Definition TGGC.h:72
Int_t GetDashLen() const
Definition TGGC.h:92
void SetFont(FontH_t v)
Set font.
Definition TGGC.cxx:403
void SetPlaneMask(ULong_t v)
Set plane mask.
Definition TGGC.cxx:259
TGGC & operator=(const TGGC &rhs)
Graphics context assignment operator.
Definition TGGC.cxx:107
GContext_t fContext
graphics context handle
Definition TGGC.h:28
void SetTileStipYOrigin(Int_t v)
Y offset for tile or stipple operations.
Definition TGGC.cxx:392
Pixmap_t GetClipMask() const
Definition TGGC.h:86
Int_t GetClipXOrigin() const
Definition TGGC.h:84
void SavePrimitive(std::ostream &out, Option_t *option="") override
Save graphics context info as a C++ statement(s) on output stream out.
Definition TGGC.cxx:619
FontH_t GetFont() const
Definition TGGC.h:82
void SetFillStyle(Int_t v)
Set fill style (kFillSolid, kFillTiled, kFillStippled, kFillOpaeueStippled).
Definition TGGC.cxx:337
Pixel_t GetForeground() const
Definition TGGC.h:73
Int_t GetFillRule() const
Definition TGGC.h:90
GCValues_t fValues
graphics context values + mask
Definition TGGC.h:27
void SetCapStyle(Int_t v)
Set cap style (kCapNotLast, kCapButt, kCapRound, kCapProjecting).
Definition TGGC.cxx:314
~TGGC() override
Delete graphics context.
Definition TGGC.cxx:95
const char * GetDashes() const
Definition TGGC.h:93
Int_t GetTileStipXOrigin() const
Definition TGGC.h:79
void SetForeground(Pixel_t v)
Set foreground color.
Definition TGGC.cxx:270
Int_t GetLineStyle() const
Definition TGGC.h:76
void SetClipMask(Pixmap_t v)
Bitmap for clipping.
Definition TGGC.cxx:458
void SetFillRule(Int_t v)
Set fill rule (kEvenOddRule, kWindingRule).
Definition TGGC.cxx:348
GContext_t operator()() const
Not inline due to a bug in g++ 2.96 20000731 (Red Hat Linux 7.0).
Definition TGGC.cxx:130
friend class TGGCPool
Definition TGGC.h:24
void SetDashOffset(Int_t v)
Patterned/dashed line offset.
Definition TGGC.cxx:469
void SetTileStipXOrigin(Int_t v)
X offset for tile or stipple operations.
Definition TGGC.cxx:381
void SetAttributes(GCValues_t *values)
Set attributes as specified in the values structure.
Definition TGGC.cxx:227
void SetDashList(const char v[], Int_t len)
Set dash pattern. First use SetDashOffset() if not 0.
Definition TGGC.cxx:480
EGraphicsFunction GetFunction() const
Definition TGGC.h:71
void SetJoinStyle(Int_t v)
Set line join style (kJoinMiter, kJoinRound, kJoinBevel).
Definition TGGC.cxx:325
void SetClipXOrigin(Int_t v)
X origin for clipping.
Definition TGGC.cxx:436
Int_t GetClipYOrigin() const
Definition TGGC.h:85
Pixel_t GetBackground() const
Definition TGGC.h:74
void SetTile(Pixmap_t v)
Set tile pixmap for tiling operations.
Definition TGGC.cxx:359
void SetClipYOrigin(Int_t v)
Y origin for clipping.
Definition TGGC.cxx:447
void Print(Option_t *option="") const override
Print graphics contexts info.
Definition TGGC.cxx:506
void UpdateValues(GCValues_t *v)
Update values + mask.
Definition TGGC.cxx:138
void SetBackground(Pixel_t v)
Set background color.
Definition TGGC.cxx:281
void SetFunction(EGraphicsFunction v)
Set graphics context drawing function.
Definition TGGC.cxx:248
void SetStipple(Pixmap_t v)
Set 1 plane pixmap for stippling.
Definition TGGC.cxx:370
Mask_t GetMask() const
Definition TGGC.h:70
Pixmap_t GetStipple() const
Definition TGGC.h:78
Int_t GetLineWidth() const
Definition TGGC.h:75
void SetGraphicsExposures(Bool_t v)
True if graphics exposure should be generated.
Definition TGGC.cxx:425
void SetLineStyle(Int_t v)
Set line style (kLineSolid, kLineOnOffDash, kLineDoubleDash).
Definition TGGC.cxx:303
Int_t GetDashOffset() const
Definition TGGC.h:91
Int_t GetCapStyle() const
Definition TGGC.h:87
const GCValues_t * GetAttributes() const
Definition TGGC.h:69
Int_t GetArcMode() const
Definition TGGC.h:94
TString GetMaskString() const
Returns GC mask as a string - used in SavePrimitive().
Definition TGGC.cxx:515
void SetSubwindowMode(Int_t v)
Set sub window mode (kClipByChildren, kIncludeInferiors).
Definition TGGC.cxx:414
TGObject & operator=(const TGObject &tgo)
Definition TGObject.h:27
TGObject()
Definition TGObject.h:38
THashTable implements a hash table to store TObject's.
Definition THashTable.h:35
TObject()
TObject constructor.
Definition TObject.h:259
TRefCnt(Int_t initRef=0)
Definition TRefCnt.h:35
Basic string class.
Definition TString.h:138
Graphics context structure.
Definition GuiTypes.h:225