Logo ROOT   6.08/07
Reference Guide
TLegend.h
Go to the documentation of this file.
1 // @(#)root/graf:$Id$
2 // Author: Matthew.Adam.Dobbs 06/09/99
3 
4 /*************************************************************************
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  *************************************************************************/
11 //--------------------------------------------------------------------------
12 #ifndef ROOT_TLegend
13 #define ROOT_TLegend
14 
15 
16 #ifndef ROOT_TPave
17 #include "TPave.h"
18 #endif
19 #ifndef ROOT_TAttText
20 #include "TAttText.h"
21 #endif
22 
23 class TObject;
24 class TList;
25 class TLegendEntry;
26 
27 class TLegend : public TPave , public TAttText {
28 
29 protected:
30  TLegend& operator=(const TLegend&);
31 
32 public:
33  TLegend();
35  const char* header = "", Option_t* option="brNDC" );
36  virtual ~TLegend();
37  TLegend( const TLegend &legend );
38 
39  TLegendEntry *AddEntry(const TObject* obj, const char* label = "", Option_t* option = "lpf" );
40  TLegendEntry *AddEntry(const char *name, const char* label = "", Option_t* option = "lpf" );
41  virtual void Clear( Option_t* option = "" ); // *MENU*
42  virtual void Copy( TObject &obj ) const;
43  virtual void DeleteEntry(); // *MENU*
44  virtual void Draw( Option_t* option = "" );
45  virtual void EditEntryAttFill();
46  virtual void EditEntryAttLine();
47  virtual void EditEntryAttMarker();
48  virtual void EditEntryAttText();
50  TLegendEntry *GetEntry() const;
52  virtual const char *GetHeader() const;
54  Float_t GetMargin() const { return fMargin; }
55  Int_t GetNColumns() const { return fNColumns; }
56  Int_t GetNRows() const;
57  virtual void InsertEntry( const char* objectName = "",const char* label = "",
58  Option_t* option = "lpf" ); // *MENU*
59  virtual void Paint( Option_t* option = "" );
60  virtual void PaintPrimitives();
61  virtual void Print( Option_t* option = "" ) const;
62  virtual void RecursiveRemove(TObject *obj);
63  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
64  void SetDefaults() { fEntrySeparation = 0.1f; fMargin = 0.25f; fNColumns = 1; fColumnSeparation = 0.0f; }
65  void SetColumnSeparation( Float_t columnSeparation )
66  { fColumnSeparation = columnSeparation; } // *MENU*
67  virtual void SetEntryLabel( const char* label ); // *MENU*
68  virtual void SetEntryOption( Option_t* option ); // *MENU*
69  void SetEntrySeparation( Float_t entryseparation )
70  { fEntrySeparation = entryseparation; } // *MENU*
71  virtual void SetHeader( const char *header = "", Option_t *option = "" ); // *MENU*
72  void SetMargin( Float_t margin ) { fMargin = margin; } // *MENU*
73  void SetNColumns( Int_t nColumns ); // *MENU*
74 
75 protected:
76  TList *fPrimitives; ///< List of TLegendEntries
77  Float_t fEntrySeparation; ///< Separation between entries, as a fraction of
78  ///< The space allocated to one entry.
79  ///< Typical value is 0.1.
80  Float_t fMargin; ///< Fraction of total width used for symbol
81  Int_t fNColumns; ///< Number of columns in the legend
82  Float_t fColumnSeparation; ///< Separation between columns, as a fraction of
83  ///< The space allowed to one column
84 
85  ClassDef(TLegend,3) // Legend of markers/lines/boxes to represent obj's
86 };
87 
88 #endif
virtual void Clear(Option_t *option="")
Clear all entries in this legend, including the header.
Definition: TLegend.cxx:340
Int_t fNColumns
Number of columns in the legend.
Definition: TLegend.h:81
This class displays a legend box (TPaveText) containing several legend entries.
Definition: TLegend.h:27
float Float_t
Definition: RtypesCore.h:53
const char Option_t
Definition: RtypesCore.h:62
virtual void EditEntryAttFill()
Edit the fill attributes for the entry pointed by the mouse.
Definition: TLegend.cxx:381
Float_t GetMargin() const
Definition: TLegend.h:54
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
Definition: TLegend.cxx:373
TLegend & operator=(const TLegend &)
Assignment operator.
Definition: TLegend.cxx:245
virtual void EditEntryAttText()
Edit the text attributes for the entry pointed by the mouse.
Definition: TLegend.cxx:414
Storage class for one entry of a TLegend.
Definition: TLegendEntry.h:36
virtual void EditEntryAttMarker()
Edit the marker attributes for the entry pointed by the mouse.
Definition: TLegend.cxx:403
int Int_t
Definition: RtypesCore.h:41
void SetMargin(Float_t margin)
Definition: TLegend.h:72
TLegend * legend
Definition: pirndm.C:35
virtual void DeleteEntry()
Delete entry at the mouse position.
Definition: TLegend.cxx:361
virtual void SetEntryLabel(const char *label)
Edit the label of the entry pointed to by the mouse.
Definition: TLegend.cxx:888
A TBox with a bordersize and a shadow option.
Definition: TPave.h:23
virtual void Print(Option_t *option="") const
Dump this TLegend and its contents.
Definition: TLegend.cxx:835
static const double x2[5]
Int_t GetNColumns() const
Definition: TLegend.h:55
#define ClassDef(name, id)
Definition: Rtypes.h:254
virtual void InsertEntry(const char *objectName="", const char *label="", Option_t *option="lpf")
Add a new entry before the entry at the mouse position.
Definition: TLegend.cxx:483
virtual const char * GetHeader() const
Returns the header, which is the title that appears at the top of the legend.
Definition: TLegend.cxx:467
virtual void SavePrimitive(std::ostream &out, Option_t *option="")
Save this legend as C++ statements on output stream out to be used with the SaveAs ...
Definition: TLegend.cxx:857
TLegendEntry * GetEntry() const
Get entry pointed to by the mouse.
Definition: TLegend.cxx:426
A doubly linked list.
Definition: TList.h:47
virtual void EditEntryAttLine()
Edit the line attributes for the entry pointed by the mouse.
Definition: TLegend.cxx:392
TList * GetListOfPrimitives() const
Definition: TLegend.h:53
void SetNColumns(Int_t nColumns)
Set the number of columns for the legend.
Definition: TLegend.cxx:538
Float_t fColumnSeparation
Separation between columns, as a fraction of The space allowed to one column.
Definition: TLegend.h:82
Int_t GetNRows() const
Get the number of rows.
Definition: TLegend.cxx:518
Text Attributes class.
Definition: TAttText.h:24
TLegend()
Default constructor.
Definition: TLegend.cxx:187
Float_t fEntrySeparation
Separation between entries, as a fraction of The space allocated to one entry.
Definition: TLegend.h:77
void SetEntrySeparation(Float_t entryseparation)
Definition: TLegend.h:69
static const double x1[5]
double Double_t
Definition: RtypesCore.h:55
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
Add a new entry to this legend.
Definition: TLegend.cxx:280
virtual void RecursiveRemove(TObject *obj)
Reset the legend entries pointing to "obj".
Definition: TLegend.cxx:844
Mother of all ROOT objects.
Definition: TObject.h:37
void SetDefaults()
Definition: TLegend.h:64
TList * fPrimitives
List of TLegendEntries.
Definition: TLegend.h:76
Float_t fMargin
Fraction of total width used for symbol.
Definition: TLegend.h:80
virtual ~TLegend()
Default destructor.
Definition: TLegend.cxx:261
Float_t GetEntrySeparation() const
Definition: TLegend.h:51
void SetColumnSeparation(Float_t columnSeparation)
Definition: TLegend.h:65
Float_t GetColumnSeparation() const
Definition: TLegend.h:49
virtual void Paint(Option_t *option="")
Paint this legend with its current attributes.
Definition: TLegend.cxx:508
virtual void Copy(TObject &obj) const
Copy this legend into "obj".
Definition: TLegend.cxx:349
char name[80]
Definition: TGX11.cxx:109
virtual void PaintPrimitives()
Paint the entries (list of primitives) for this legend.
Definition: TLegend.cxx:550
virtual void SetEntryOption(Option_t *option)
Edit the option of the entry pointed to by the mouse.
Definition: TLegend.cxx:897
virtual void SetHeader(const char *header="", Option_t *option="")
Sets the header, which is the "title" that appears at the top of the legend.
Definition: TLegend.cxx:907