Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/TGGC.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // @(#)root/gui:$Id$
0002 // Author: Fons Rademakers   20/9/2000
0003 
0004 /*************************************************************************
0005  * Copyright (C) 1995-2021, Rene Brun and Fons Rademakers.               *
0006  * All rights reserved.                                                  *
0007  *                                                                       *
0008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0010  *************************************************************************/
0011 
0012 #ifndef ROOT_TGGC
0013 #define ROOT_TGGC
0014 
0015 
0016 #include "TGObject.h"
0017 #include "TRefCnt.h"
0018 
0019 class THashTable;
0020 
0021 
0022 class TGGC : public TObject, public TRefCnt {
0023 
0024 friend class TGGCPool;
0025 
0026 protected:
0027    GCValues_t fValues = {}; ///< graphics context values + mask
0028    GContext_t fContext;     ///< graphics context handle
0029 
0030    TGGC(GCValues_t *values, Bool_t calledByGCPool);
0031    void UpdateValues(GCValues_t *v);
0032 
0033    TString GetMaskString() const;    //used in SavePrimitive()
0034 
0035 public:
0036    TGGC(GCValues_t *values = nullptr);
0037    TGGC(const TGGC &g);
0038    ~TGGC() override;
0039    TGGC &operator=(const TGGC &rhs);
0040 
0041    GContext_t GetGC() const { return fContext; }
0042    GContext_t operator()() const;
0043 
0044    void SetAttributes(GCValues_t *values);
0045    void SetFunction(EGraphicsFunction v);
0046    void SetPlaneMask(ULong_t v);
0047    void SetForeground(Pixel_t v);
0048    void SetBackground(Pixel_t v);
0049    void SetLineWidth(Int_t v);
0050    void SetLineStyle(Int_t v);
0051    void SetCapStyle(Int_t v);
0052    void SetJoinStyle(Int_t v);
0053    void SetFillStyle(Int_t v);
0054    void SetFillRule(Int_t v);
0055    void SetTile(Pixmap_t v);
0056    void SetStipple(Pixmap_t v);
0057    void SetTileStipXOrigin(Int_t v);
0058    void SetTileStipYOrigin(Int_t v);
0059    void SetFont(FontH_t v);
0060    void SetSubwindowMode(Int_t v);
0061    void SetGraphicsExposures(Bool_t v);
0062    void SetClipXOrigin(Int_t v);
0063    void SetClipYOrigin(Int_t v);
0064    void SetClipMask(Pixmap_t v);
0065    void SetDashOffset(Int_t v);
0066    void SetDashList(const char v[], Int_t len);
0067    void SetArcMode(Int_t v);
0068 
0069    const GCValues_t *GetAttributes() const { return &fValues; }
0070    Mask_t            GetMask() const { return fValues.fMask; }
0071    EGraphicsFunction GetFunction() const { return fValues.fFunction; }
0072    ULong_t           GetPlaneMask() const { return fValues.fPlaneMask; }
0073    Pixel_t           GetForeground() const { return fValues.fForeground; }
0074    Pixel_t           GetBackground() const { return fValues.fBackground; }
0075    Int_t             GetLineWidth() const { return fValues.fLineWidth; }
0076    Int_t             GetLineStyle() const { return fValues.fLineStyle; }
0077    Pixmap_t          GetTile() const { return fValues.fTile; }
0078    Pixmap_t          GetStipple() const { return fValues.fStipple; }
0079    Int_t             GetTileStipXOrigin() const { return fValues.fTsXOrigin; }
0080    Int_t             GetTileStipYOrigin() const { return fValues.fTsYOrigin; }
0081    Int_t             GetSubwindowMode() const { return fValues.fSubwindowMode; }
0082    FontH_t           GetFont() const { return fValues.fFont; }
0083    Bool_t            GetGraphicsExposures() const { return fValues.fGraphicsExposures; }
0084    Int_t             GetClipXOrigin() const { return fValues.fClipXOrigin; }
0085    Int_t             GetClipYOrigin() const { return fValues.fClipYOrigin; }
0086    Pixmap_t          GetClipMask() const { return fValues.fClipMask; }
0087    Int_t             GetCapStyle() const { return fValues.fCapStyle; }
0088    Int_t             GetJoinStyle() const { return fValues.fJoinStyle; }
0089    Int_t             GetFillStyle() const { return fValues.fFillStyle; }
0090    Int_t             GetFillRule() const { return fValues.fFillRule; }
0091    Int_t             GetDashOffset() const { return fValues.fDashOffset; }
0092    Int_t             GetDashLen() const { return fValues.fDashLen; }
0093    const char       *GetDashes() const { return fValues.fDashes; }
0094    Int_t             GetArcMode() const { return fValues.fArcMode; }
0095 
0096    void Print(Option_t *option="") const override;
0097    void SavePrimitive(std::ostream &out, Option_t *option = "") override;
0098 
0099    ClassDefOverride(TGGC,0)  // Graphics context
0100 };
0101 
0102 
0103 class TGGCPool : public TGObject {
0104 
0105 friend class TGGC;
0106 
0107 private:
0108    THashTable  *fList;   // hash table of graphics contexts in pool
0109 
0110    void   ForceFreeGC(const TGGC *gc);
0111    Int_t  MatchGC(const TGGC *gc, GCValues_t *values);
0112    void   UpdateGC(TGGC *gc, GCValues_t *values);
0113 
0114 protected:
0115    TGGCPool(const TGGCPool& gp) : TGObject(gp), fList(gp.fList) { }
0116    TGGCPool& operator=(const TGGCPool& gp)
0117    {
0118       if (this != &gp) {
0119          TGObject::operator=(gp);
0120          fList = gp.fList;
0121       }
0122       return *this;
0123    }
0124 
0125 public:
0126    TGGCPool(TGClient *client);
0127    ~TGGCPool() override;
0128 
0129    TGGC *GetGC(GCValues_t *values, Bool_t rw = kFALSE);
0130    TGGC *GetGC(GContext_t gct);
0131    void  FreeGC(const TGGC *gc);
0132    void  FreeGC(GContext_t gc);
0133 
0134    TGGC *FindGC(const TGGC *gc);
0135    TGGC *FindGC(GContext_t gc);
0136 
0137    void  Print(Option_t *option="") const override;
0138 
0139    ClassDefOverride(TGGCPool,0)  // Graphics context pool
0140 };
0141 
0142 #endif