TGPicture.h

Go to the documentation of this file.
00001 // @(#)root/gui:$Id: TGPicture.h 23115 2008-04-10 13:35:37Z rdm $
00002 // Author: Fons Rademakers   01/01/98
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_TGPicture
00013 #define ROOT_TGPicture
00014 
00015 
00016 //////////////////////////////////////////////////////////////////////////
00017 //                                                                      //
00018 // TGPicture, TGSelectdPicture & TGPicturePool                          //
00019 //                                                                      //
00020 // The TGPicture class implements pictures and icons used in the        //
00021 // different GUI elements and widgets. The TGPicturePool class          //
00022 // implements a TGPicture cache. TGPictures are created, managed and    //
00023 // destroyed by the TGPicturePool.                                      //
00024 //                                                                      //
00025 //////////////////////////////////////////////////////////////////////////
00026 
00027 #ifndef ROOT_TObject
00028 #include "TObject.h"
00029 #endif
00030 #ifndef ROOT_TRefCnt
00031 #include "TRefCnt.h"
00032 #endif
00033 #ifndef ROOT_TString
00034 #include "TString.h"
00035 #endif
00036 #ifndef ROOT_TGClient
00037 #include "TGClient.h"
00038 #endif
00039 #ifndef ROOT_TGGC
00040 #include "TGGC.h"
00041 #endif
00042 
00043 class THashTable;
00044 
00045 
00046 class TGPicture : public TObject, public TRefCnt {
00047 
00048 friend class TGPicturePool;
00049 
00050 protected:
00051    TString             fName;       // name of picture
00052    Bool_t              fScaled;     // kTRUE if picture is scaled
00053    Pixmap_t            fPic;        // picture pixmap
00054    Pixmap_t            fMask;       // picture mask pixmap
00055    PictureAttributes_t fAttributes; // picture attributes
00056 
00057    TGPicture(const char *name, Bool_t scaled = kFALSE):
00058       fName(name), fScaled(scaled), fPic(kNone), fMask(kNone), fAttributes()
00059    {
00060       fAttributes.fPixels = 0;
00061       SetRefCount(1);
00062    }
00063 
00064    TGPicture(const char *name, Pixmap_t pxmap, Pixmap_t mask = 0);
00065 
00066    // override default of TObject
00067    void Draw(Option_t * = "") { MayNotUse("Draw(Option_t*)"); }
00068 
00069 public:
00070    virtual ~TGPicture();
00071 
00072    const char *GetName() const { return fName; }
00073    UInt_t      GetWidth() const { return fAttributes.fWidth; }
00074    UInt_t      GetHeight() const { return fAttributes.fHeight; }
00075    Pixmap_t    GetPicture() const { return fPic; }
00076    Pixmap_t    GetMask() const { return fMask; }
00077    Bool_t      IsScaled() const { return fScaled; }
00078    ULong_t     Hash() const { return fName.Hash(); }
00079    static const char *HashName(const char *name, Int_t width, Int_t height);
00080 
00081    virtual void Draw(Handle_t id, GContext_t gc, Int_t x, Int_t y) const;
00082    void         Print(Option_t *option="") const;
00083 
00084    ClassDef(TGPicture,0)  // Pictures and icons used by the GUI classes
00085 };
00086 
00087 
00088 class TGSelectedPicture : public TGPicture {
00089 
00090 protected:
00091    const TGClient *fClient;    // client to which selected picture belongs
00092 
00093    static TGGC *fgSelectedGC;
00094    static TGGC &GetSelectedGC();
00095 
00096    TGSelectedPicture(const TGSelectedPicture& gp):
00097      TGPicture(gp), fClient(gp.fClient) { }
00098    TGSelectedPicture& operator=(const TGSelectedPicture& gp)
00099      {if(this!=&gp) { TGPicture::operator=(gp); fClient=gp.fClient;}
00100      return *this;}
00101 
00102 public:
00103    TGSelectedPicture(const TGClient *client, const TGPicture *p);
00104    virtual ~TGSelectedPicture();
00105 
00106    ClassDef(TGSelectedPicture,0)  // Selected looking picture
00107 };
00108 
00109 
00110 class TGPicturePool : public TObject {
00111 
00112 protected:
00113    const TGClient    *fClient;    // client for which we keep icon pool
00114    TString            fPath;      // icon search path
00115    THashTable        *fPicList;   // hash table containing the icons
00116 
00117    TGPicturePool(const TGPicturePool&);
00118    TGPicturePool& operator=(const TGPicturePool&);
00119 
00120 public:
00121    TGPicturePool(const TGClient *client, const char *path):
00122       fClient(client), fPath(path), fPicList(0) { }
00123    virtual ~TGPicturePool();
00124 
00125    const char      *GetPath() const { return fPath; }
00126    const TGPicture *GetPicture(const char *name);
00127    const TGPicture *GetPicture(const char *name, char **xpm);
00128    const TGPicture *GetPicture(const char *name, UInt_t new_width, UInt_t new_height);
00129    const TGPicture *GetPicture(const char *name, Pixmap_t pxmap, Pixmap_t mask =  0);
00130    void             FreePicture(const TGPicture *pic);
00131 
00132    void             Print(Option_t *option="") const;
00133 
00134    ClassDef(TGPicturePool,0)  // Picture and icon cache
00135 };
00136 
00137 #endif

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