Logo ROOT  
Reference Guide
Go to the documentation of this file.
1// @(#)root/gui:$Id$
2// Author: Fons Rademakers 01/01/98
5 * Copyright (C) 1995-2000, 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 *************************************************************************/
12#ifndef ROOT_TGPicture
13#define ROOT_TGPicture
16#include "TObject.h"
17#include "TRefCnt.h"
18#include "TString.h"
19#include "TGClient.h"
20#include "TGGC.h"
22class THashTable;
25class TGPicture : public TObject, public TRefCnt {
27friend class TGPicturePool;
30 TString fName; ///< name of picture
31 Bool_t fScaled; ///< kTRUE if picture is scaled
32 Pixmap_t fPic; ///< picture pixmap
33 Pixmap_t fMask; ///< picture mask pixmap
34 PictureAttributes_t fAttributes; ///< picture attributes
36 TGPicture(const char *name, Bool_t scaled = kFALSE):
38 {
40 SetRefCount(1);
41 }
43 TGPicture(const char *name, Pixmap_t pxmap, Pixmap_t mask = 0);
45 // override default of TObject
46 void Draw(Option_t * = "") override { MayNotUse("Draw(Option_t*)"); }
49 virtual ~TGPicture();
51 const char *GetName() const override { return fName.Data(); }
52 UInt_t GetWidth() const { return fAttributes.fWidth; }
53 UInt_t GetHeight() const { return fAttributes.fHeight; }
54 Pixmap_t GetPicture() const { return fPic; }
55 Pixmap_t GetMask() const { return fMask; }
56 Bool_t IsScaled() const { return fScaled; }
57 ULong_t Hash() const override { return fName.Hash(); }
58 static const char *HashName(const char *name, Int_t width, Int_t height);
60 virtual void Draw(Handle_t id, GContext_t gc, Int_t x, Int_t y) const;
61 void Print(Option_t *option="") const override;
63 ClassDefOverride(TGPicture,0) // Pictures and icons used by the GUI classes
70 const TGClient *fClient; // client to which selected picture belongs
73 static TGGC &GetSelectedGC();
76 TGPicture(gp), fClient(gp.fClient) { }
78 {if(this!=&gp) { TGPicture::operator=(gp); fClient=gp.fClient;}
79 return *this;}
82 TGSelectedPicture(const TGClient *client, const TGPicture *p);
83 virtual ~TGSelectedPicture();
85 ClassDefOverride(TGSelectedPicture,0) // Selected looking picture
89class TGPicturePool : public TObject {
92 const TGClient *fClient; ///< client for which we keep icon pool
93 TString fPath; ///< icon search path
94 THashTable *fPicList; ///< hash table containing the icons
100 TGPicturePool(const TGClient *client, const char *path):
101 fClient(client), fPath(path), fPicList(nullptr) { }
102 virtual ~TGPicturePool();
104 const char *GetPath() const { return fPath; }
105 const TGPicture *GetPicture(const char *name);
106 const TGPicture *GetPicture(const char *name, char **xpm);
107 const TGPicture *GetPicture(const char *name, UInt_t new_width, UInt_t new_height);
108 const TGPicture *GetPicture(const char *name, Pixmap_t pxmap, Pixmap_t mask = 0);
109 void FreePicture(const TGPicture *pic);
111 void Print(Option_t *option="") const override;
113 ClassDefOverride(TGPicturePool,0) // Picture and icon cache
Handle_t Pixmap_t
Pixmap handle.
Definition: GuiTypes.h:30
Handle_t GContext_t
Graphics context handle.
Definition: GuiTypes.h:38
const Handle_t kNone
Definition: GuiTypes.h:88
ULongptr_t Handle_t
Generic resource handle.
Definition: GuiTypes.h:26
int Int_t
Definition: RtypesCore.h:45
const Bool_t kFALSE
Definition: RtypesCore.h:101
unsigned int UInt_t
Definition: RtypesCore.h:46
unsigned long ULong_t
Definition: RtypesCore.h:55
const char Option_t
Definition: RtypesCore.h:66
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t mask
Option_t Option_t width
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t height
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void gc
char name[80]
Definition: TGX11.cxx:110
Window client.
Definition: TGClient.h:37
Encapsulate a graphics context used in the low level graphics.
Definition: TGGC.h:22
const char * GetPath() const
Definition: TGPicture.h:104
virtual ~TGPicturePool()
Delete picture cache.
Definition: TGPicture.cxx:293
TString fPath
icon search path
Definition: TGPicture.h:93
THashTable * fPicList
hash table containing the icons
Definition: TGPicture.h:94
TGPicturePool(const TGPicturePool &)
copy constructor
Definition: TGPicture.cxx:56
void Print(Option_t *option="") const override
List all pictures in the pool.
Definition: TGPicture.cxx:307
void FreePicture(const TGPicture *pic)
Remove picture from cache if nobody is using it anymore.
Definition: TGPicture.cxx:277
const TGClient * fClient
client for which we keep icon pool
Definition: TGPicture.h:92
const TGPicture * GetPicture(const char *name)
Get a picture from the picture pool.
Definition: TGPicture.cxx:82
TGPicturePool & operator=(const TGPicturePool &)
assignment operator
Definition: TGPicture.cxx:67
TGPicturePool(const TGClient *client, const char *path)
Definition: TGPicture.h:100
The TGPicture class implements pictures and icons used in the different GUI elements and widgets.
Definition: TGPicture.h:25
Pixmap_t fPic
picture pixmap
Definition: TGPicture.h:32
PictureAttributes_t fAttributes
picture attributes
Definition: TGPicture.h:34
static const char * HashName(const char *name, Int_t width, Int_t height)
Static function returning a unique name used to look up a picture.
Definition: TGPicture.cxx:375
void Print(Option_t *option="") const override
Print picture info.
Definition: TGPicture.cxx:386
Pixmap_t fMask
picture mask pixmap
Definition: TGPicture.h:33
Pixmap_t GetMask() const
Definition: TGPicture.h:55
Bool_t IsScaled() const
Definition: TGPicture.h:56
void Draw(Option_t *="") override
Default Draw method for all objects.
Definition: TGPicture.h:46
TGPicture(const char *name, Bool_t scaled=kFALSE)
Definition: TGPicture.h:36
UInt_t GetHeight() const
Definition: TGPicture.h:53
const char * GetName() const override
Returns name of object.
Definition: TGPicture.h:51
Pixmap_t GetPicture() const
Definition: TGPicture.h:54
virtual ~TGPicture()
Delete picture object.
Definition: TGPicture.cxx:361
ULong_t Hash() const override
Return hash value for this object.
Definition: TGPicture.h:57
Bool_t fScaled
kTRUE if picture is scaled
Definition: TGPicture.h:31
TString fName
name of picture
Definition: TGPicture.h:30
UInt_t GetWidth() const
Definition: TGPicture.h:52
static TGGC & GetSelectedGC()
Return selection graphics context in use.
Definition: TGPicture.cxx:439
static TGGC * fgSelectedGC
Definition: TGPicture.h:72
TGSelectedPicture(const TGSelectedPicture &gp)
Definition: TGPicture.h:75
virtual ~TGSelectedPicture()
Delete selected picture.
Definition: TGPicture.cxx:430
const TGClient * fClient
Definition: TGPicture.h:70
TGSelectedPicture & operator=(const TGSelectedPicture &gp)
Definition: TGPicture.h:77
THashTable implements a hash table to store TObject's.
Definition: THashTable.h:35
Mother of all ROOT objects.
Definition: TObject.h:37
TObject & operator=(const TObject &rhs)
TObject assignment operator.
Definition: TObject.h:283
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
Definition: TObject.cxx:946
Definitions for TRefCnt, base class for reference counted objects.
Definition: TRefCnt.h:27
void SetRefCount(UInt_t r)
Definition: TRefCnt.h:39
Basic string class.
Definition: TString.h:136
const char * Data() const
Definition: TString.h:369
UInt_t Hash(ECaseCompare cmp=kExact) const
Return hash value.
Definition: TString.cxx:662
Double_t y[n]
Definition: legend1.C:17
Double_t x[n]
Definition: legend1.C:17
UInt_t fHeight
height of picture
Definition: GuiTypes.h:327
ULong_t * fPixels
list of used color pixels (if set use delete[])
Definition: GuiTypes.h:330
UInt_t fWidth
width of picture
Definition: GuiTypes.h:326