ROOT logo
// @(#)root/gui:$Id: TGPicture.h 23115 2008-04-10 13:35:37Z rdm $
// Author: Fons Rademakers   01/01/98

/*************************************************************************
 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TGPicture
#define ROOT_TGPicture


//////////////////////////////////////////////////////////////////////////
//                                                                      //
// TGPicture, TGSelectdPicture & TGPicturePool                          //
//                                                                      //
// The TGPicture class implements pictures and icons used in the        //
// different GUI elements and widgets. The TGPicturePool class          //
// implements a TGPicture cache. TGPictures are created, managed and    //
// destroyed by the TGPicturePool.                                      //
//                                                                      //
//////////////////////////////////////////////////////////////////////////

#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TRefCnt
#include "TRefCnt.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TGClient
#include "TGClient.h"
#endif
#ifndef ROOT_TGGC
#include "TGGC.h"
#endif

class THashTable;


class TGPicture : public TObject, public TRefCnt {

friend class TGPicturePool;

protected:
   TString             fName;       // name of picture
   Bool_t              fScaled;     // kTRUE if picture is scaled
   Pixmap_t            fPic;        // picture pixmap
   Pixmap_t            fMask;       // picture mask pixmap
   PictureAttributes_t fAttributes; // picture attributes

   TGPicture(const char *name, Bool_t scaled = kFALSE):
      fName(name), fScaled(scaled), fPic(kNone), fMask(kNone), fAttributes()
   {
      fAttributes.fPixels = 0;
      SetRefCount(1);
   }

   TGPicture(const char *name, Pixmap_t pxmap, Pixmap_t mask = 0);

   // override default of TObject
   void Draw(Option_t * = "") { MayNotUse("Draw(Option_t*)"); }

public:
   virtual ~TGPicture();

   const char *GetName() const { return fName; }
   UInt_t      GetWidth() const { return fAttributes.fWidth; }
   UInt_t      GetHeight() const { return fAttributes.fHeight; }
   Pixmap_t    GetPicture() const { return fPic; }
   Pixmap_t    GetMask() const { return fMask; }
   Bool_t      IsScaled() const { return fScaled; }
   ULong_t     Hash() const { return fName.Hash(); }
   static const char *HashName(const char *name, Int_t width, Int_t height);

   virtual void Draw(Handle_t id, GContext_t gc, Int_t x, Int_t y) const;
   void         Print(Option_t *option="") const;

   ClassDef(TGPicture,0)  // Pictures and icons used by the GUI classes
};


class TGSelectedPicture : public TGPicture {

protected:
   const TGClient *fClient;    // client to which selected picture belongs

   static TGGC *fgSelectedGC;
   static TGGC &GetSelectedGC();

   TGSelectedPicture(const TGSelectedPicture& gp):
     TGPicture(gp), fClient(gp.fClient) { }
   TGSelectedPicture& operator=(const TGSelectedPicture& gp)
     {if(this!=&gp) { TGPicture::operator=(gp); fClient=gp.fClient;}
     return *this;}

public:
   TGSelectedPicture(const TGClient *client, const TGPicture *p);
   virtual ~TGSelectedPicture();

   ClassDef(TGSelectedPicture,0)  // Selected looking picture
};


class TGPicturePool : public TObject {

protected:
   const TGClient    *fClient;    // client for which we keep icon pool
   TString            fPath;      // icon search path
   THashTable        *fPicList;   // hash table containing the icons

   TGPicturePool(const TGPicturePool&);
   TGPicturePool& operator=(const TGPicturePool&);

public:
   TGPicturePool(const TGClient *client, const char *path):
      fClient(client), fPath(path), fPicList(0) { }
   virtual ~TGPicturePool();

   const char      *GetPath() const { return fPath; }
   const TGPicture *GetPicture(const char *name);
   const TGPicture *GetPicture(const char *name, char **xpm);
   const TGPicture *GetPicture(const char *name, UInt_t new_width, UInt_t new_height);
   const TGPicture *GetPicture(const char *name, Pixmap_t pxmap, Pixmap_t mask =  0);
   void             FreePicture(const TGPicture *pic);

   void             Print(Option_t *option="") const;

   ClassDef(TGPicturePool,0)  // Picture and icon cache
};

#endif
 TGPicture.h:1
 TGPicture.h:2
 TGPicture.h:3
 TGPicture.h:4
 TGPicture.h:5
 TGPicture.h:6
 TGPicture.h:7
 TGPicture.h:8
 TGPicture.h:9
 TGPicture.h:10
 TGPicture.h:11
 TGPicture.h:12
 TGPicture.h:13
 TGPicture.h:14
 TGPicture.h:15
 TGPicture.h:16
 TGPicture.h:17
 TGPicture.h:18
 TGPicture.h:19
 TGPicture.h:20
 TGPicture.h:21
 TGPicture.h:22
 TGPicture.h:23
 TGPicture.h:24
 TGPicture.h:25
 TGPicture.h:26
 TGPicture.h:27
 TGPicture.h:28
 TGPicture.h:29
 TGPicture.h:30
 TGPicture.h:31
 TGPicture.h:32
 TGPicture.h:33
 TGPicture.h:34
 TGPicture.h:35
 TGPicture.h:36
 TGPicture.h:37
 TGPicture.h:38
 TGPicture.h:39
 TGPicture.h:40
 TGPicture.h:41
 TGPicture.h:42
 TGPicture.h:43
 TGPicture.h:44
 TGPicture.h:45
 TGPicture.h:46
 TGPicture.h:47
 TGPicture.h:48
 TGPicture.h:49
 TGPicture.h:50
 TGPicture.h:51
 TGPicture.h:52
 TGPicture.h:53
 TGPicture.h:54
 TGPicture.h:55
 TGPicture.h:56
 TGPicture.h:57
 TGPicture.h:58
 TGPicture.h:59
 TGPicture.h:60
 TGPicture.h:61
 TGPicture.h:62
 TGPicture.h:63
 TGPicture.h:64
 TGPicture.h:65
 TGPicture.h:66
 TGPicture.h:67
 TGPicture.h:68
 TGPicture.h:69
 TGPicture.h:70
 TGPicture.h:71
 TGPicture.h:72
 TGPicture.h:73
 TGPicture.h:74
 TGPicture.h:75
 TGPicture.h:76
 TGPicture.h:77
 TGPicture.h:78
 TGPicture.h:79
 TGPicture.h:80
 TGPicture.h:81
 TGPicture.h:82
 TGPicture.h:83
 TGPicture.h:84
 TGPicture.h:85
 TGPicture.h:86
 TGPicture.h:87
 TGPicture.h:88
 TGPicture.h:89
 TGPicture.h:90
 TGPicture.h:91
 TGPicture.h:92
 TGPicture.h:93
 TGPicture.h:94
 TGPicture.h:95
 TGPicture.h:96
 TGPicture.h:97
 TGPicture.h:98
 TGPicture.h:99
 TGPicture.h:100
 TGPicture.h:101
 TGPicture.h:102
 TGPicture.h:103
 TGPicture.h:104
 TGPicture.h:105
 TGPicture.h:106
 TGPicture.h:107
 TGPicture.h:108
 TGPicture.h:109
 TGPicture.h:110
 TGPicture.h:111
 TGPicture.h:112
 TGPicture.h:113
 TGPicture.h:114
 TGPicture.h:115
 TGPicture.h:116
 TGPicture.h:117
 TGPicture.h:118
 TGPicture.h:119
 TGPicture.h:120
 TGPicture.h:121
 TGPicture.h:122
 TGPicture.h:123
 TGPicture.h:124
 TGPicture.h:125
 TGPicture.h:126
 TGPicture.h:127
 TGPicture.h:128
 TGPicture.h:129
 TGPicture.h:130
 TGPicture.h:131
 TGPicture.h:132
 TGPicture.h:133
 TGPicture.h:134
 TGPicture.h:135
 TGPicture.h:136
 TGPicture.h:137