TGGC.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGGC.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   20/9/2000
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #ifndef ROOT_TGGC
00013 #define ROOT_TGGC
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGGC and TGGCPool                                                    //
00019 //                                                                      //
00020 // Encapsulate a graphics context used in the low level graphics.       //
00021 // TGGCPool provides a pool of graphics contexts.                       //
00022 //                                                                      //
00023 //////////////////////////////////////////////////////////////////////////
00024 
00025 #ifndef ROOT_TGObject
00026 #include "TGObject.h"
00027 #endif
00028 #ifndef ROOT_TRefCnt
00029 #include "TRefCnt.h"
00030 #endif
00031 
00032 class THashTable;
00033 
00034 
00035 class TGGC : public TObject, public TRefCnt {
00036 
00037 friend class TGGCPool;
00038 
00039 protected:
00040    GCValues_t     fValues;     // graphics context values + mask
00041    GContext_t     fContext;    // graphics context handle
00042 
00043    TGGC(GCValues_t *values, Bool_t calledByGCPool);
00044    void UpdateValues(GCValues_t *v);
00045 
00046    TString GetMaskString() const;    //used in SavePrimitive()
00047 
00048 public:
00049    TGGC(GCValues_t *values = 0);
00050    TGGC(const TGGC &g);
00051    virtual ~TGGC();
00052    TGGC &operator=(const TGGC &rhs);
00053 
00054    GContext_t GetGC() const { return fContext; }
00055    GContext_t operator()() const;
00056 
00057    void SetAttributes(GCValues_t *values);
00058    void SetFunction(EGraphicsFunction v);
00059    void SetPlaneMask(ULong_t v);
00060    void SetForeground(Pixel_t v);
00061    void SetBackground(Pixel_t v);
00062    void SetLineWidth(Int_t v);
00063    void SetLineStyle(Int_t v);
00064    void SetCapStyle(Int_t v);
00065    void SetJoinStyle(Int_t v);
00066    void SetFillStyle(Int_t v);
00067    void SetFillRule(Int_t v);
00068    void SetTile(Pixmap_t v);
00069    void SetStipple(Pixmap_t v);
00070    void SetTileStipXOrigin(Int_t v);
00071    void SetTileStipYOrigin(Int_t v);
00072    void SetFont(FontH_t v);
00073    void SetSubwindowMode(Int_t v);
00074    void SetGraphicsExposures(Bool_t v);
00075    void SetClipXOrigin(Int_t v);
00076    void SetClipYOrigin(Int_t v);
00077    void SetClipMask(Pixmap_t v);
00078    void SetDashOffset(Int_t v);
00079    void SetDashList(const char v[], Int_t len);
00080    void SetArcMode(Int_t v);
00081 
00082    const GCValues_t *GetAttributes() const { return &fValues; }
00083    Mask_t            GetMask() const { return fValues.fMask; }
00084    EGraphicsFunction GetFunction() const { return fValues.fFunction; }
00085    ULong_t           GetPlaneMask() const { return fValues.fPlaneMask; }
00086    Pixel_t           GetForeground() const { return fValues.fForeground; }
00087    Pixel_t           GetBackground() const { return fValues.fBackground; }
00088    Int_t             GetLineWidth() const { return fValues.fLineWidth; }
00089    Int_t             GetLineStyle() const { return fValues.fLineStyle; }
00090    Pixmap_t          GetTile() const { return fValues.fTile; }
00091    Pixmap_t          GetStipple() const { return fValues.fStipple; }
00092    Int_t             GetTileStipXOrigin() const { return fValues.fTsXOrigin; }
00093    Int_t             GetTileStipYOrigin() const { return fValues.fTsYOrigin; }
00094    Int_t             GetSubwindowMode() const { return fValues.fSubwindowMode; }
00095    FontH_t           GetFont() const { return fValues.fFont; }
00096    Bool_t            GetGraphicsExposures() const { return fValues.fGraphicsExposures; }
00097    Int_t             GetClipXOrigin() const { return fValues.fClipXOrigin; }
00098    Int_t             GetClipYOrigin() const { return fValues.fClipYOrigin; }
00099    Pixmap_t          GetClipMask() const { return fValues.fClipMask; }
00100    Int_t             GetCapStyle() const { return fValues.fCapStyle; }
00101    Int_t             GetJoinStyle() const { return fValues.fJoinStyle; }
00102    Int_t             GetFillStyle() const { return fValues.fFillStyle; }
00103    Int_t             GetFillRule() const { return fValues.fFillRule; }
00104    Int_t             GetDashOffset() const { return fValues.fDashOffset; }
00105    Int_t             GetDashLen() const { return fValues.fDashLen; }
00106    const char       *GetDashes() const { return fValues.fDashes; }
00107    Int_t             GetArcMode() const { return fValues.fArcMode; }
00108 
00109    void Print(Option_t *option="") const;
00110    void SavePrimitive(ostream &out, Option_t *option = "");
00111 
00112    ClassDef(TGGC,0)  // Graphics context
00113 };
00114 
00115 
00116 class TGGCPool : public TGObject {
00117 
00118 friend class TGGC;
00119 
00120 private:
00121    THashTable  *fList;   // hash table of graphics contexts in pool
00122 
00123    void   ForceFreeGC(const TGGC *gc);
00124    Int_t  MatchGC(const TGGC *gc, GCValues_t *values);
00125    void   UpdateGC(TGGC *gc, GCValues_t *values);
00126 
00127 protected:
00128    TGGCPool(const TGGCPool& gp) : TGObject(gp), fList(gp.fList) { }
00129    TGGCPool& operator=(const TGGCPool& gp)
00130      {if(this!=&gp) {TGObject::operator=(gp); fList=gp.fList;}
00131      return *this;}
00132 
00133 public:
00134    TGGCPool(TGClient *client);
00135    virtual ~TGGCPool();
00136 
00137    TGGC *GetGC(GCValues_t *values, Bool_t rw = kFALSE);
00138    TGGC *GetGC(GContext_t gct);
00139    void  FreeGC(const TGGC *gc);
00140    void  FreeGC(GContext_t gc);
00141 
00142    TGGC *FindGC(const TGGC *gc);
00143    TGGC *FindGC(GContext_t gc);
00144 
00145    void  Print(Option_t *option="") const;
00146 
00147    ClassDef(TGGCPool,0)  // Graphics context pool
00148 };
00149 
00150 #endif

Generated on Tue Jul 5 14:20:02 2011 for ROOT_528-00b_version by  doxygen 1.5.1