ROOT  6.06/09
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 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TLegend (a second attempt- the first was TPadLegend //
19 // Matthew.Adam.Dobbs@Cern.CH, September 1999 //
20 // Legend of markers/lines/boxes for histos & graphs //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #ifndef ROOT_TPave
25 #include "TPave.h"
26 #endif
27 #ifndef ROOT_TAttText
28 #include "TAttText.h"
29 #endif
30 
31 class TObject;
32 class TList;
33 class TLegendEntry;
34 
35 class TLegend : public TPave , public TAttText {
36 
37 protected:
38  TLegend& operator=(const TLegend&);
39 
40 public:
41  TLegend();
43  const char* header = "", Option_t* option="brNDC" );
44  virtual ~TLegend();
45  TLegend( const TLegend &legend );
46 
47  TLegendEntry *AddEntry(const TObject* obj, const char* label = "", Option_t* option = "lpf" );
48  TLegendEntry *AddEntry(const char *name, const char* label = "", Option_t* option = "lpf" );
49  virtual void Clear( Option_t* option = "" ); // *MENU*
50  virtual void Copy( TObject &obj ) const;
51  virtual void DeleteEntry(); // *MENU*
52  virtual void Draw( Option_t* option = "" );
53  virtual void EditEntryAttFill();
54  virtual void EditEntryAttLine();
55  virtual void EditEntryAttMarker();
56  virtual void EditEntryAttText();
58  TLegendEntry *GetEntry() const;
60  virtual const char *GetHeader() const;
62  Float_t GetMargin() const { return fMargin; }
63  Int_t GetNColumns() const { return fNColumns; }
64  Int_t GetNRows() const;
65  virtual void InsertEntry( const char* objectName = "",const char* label = "",
66  Option_t* option = "lpf" ); // *MENU*
67  virtual void Paint( Option_t* option = "" );
68  virtual void PaintPrimitives();
69  virtual void Print( Option_t* option = "" ) const;
70  virtual void RecursiveRemove(TObject *obj);
71  virtual void SavePrimitive(std::ostream &out, Option_t *option = "");
72  void SetDefaults() { fEntrySeparation = 0.1f; fMargin = 0.25f; fNColumns = 1; fColumnSeparation = 0.0f; }
73  void SetColumnSeparation( Float_t columnSeparation )
74  { fColumnSeparation = columnSeparation; } // *MENU*
75  virtual void SetEntryLabel( const char* label ); // *MENU*
76  virtual void SetEntryOption( Option_t* option ); // *MENU*
77  void SetEntrySeparation( Float_t entryseparation )
78  { fEntrySeparation = entryseparation; } // *MENU*
79  virtual void SetHeader( const char *header = "" ); // *MENU*
80  void SetMargin( Float_t margin ) { fMargin = margin; } // *MENU*
81  void SetNColumns( Int_t nColumns ); // *MENU*
82 
83 protected:
84  TList *fPrimitives; // list of TLegendEntries
85  Float_t fEntrySeparation; // separation between entries, as a fraction of
86  // the space allocated to one entry.
87  // Typical value is 0.1.
88  Float_t fMargin; // fraction of total width used for symbol
89  Int_t fNColumns; // number of columns in the legend
90  Float_t fColumnSeparation; // separation between columns, as a fraction of
91  // the space allowed to one column
92 
93  ClassDef(TLegend,2) // Legend of markers/lines/boxes to represent obj's
94 };
95 
96 #endif
virtual void Clear(Option_t *option="")
Clear all entries in this legend, including the header.
Definition: TLegend.cxx:340
Int_t GetNRows() const
Get the number of rows.
Definition: TLegend.cxx:518
virtual void Copy(TObject &obj) const
Copy this legend into "obj".
Definition: TLegend.cxx:349
Int_t fNColumns
Definition: TLegend.h:89
This class displays a legend box (TPaveText) containing several legend entries.
Definition: TLegend.h:35
ClassDef(TAttBBox2D, 0)
TList * GetListOfPrimitives() const
Definition: TLegend.h:61
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
virtual void Draw(Option_t *option="")
Draw this legend with its current attributes.
Definition: TLegend.cxx:373
Int_t GetNColumns() const
Definition: TLegend.h:63
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
TLegendEntry * GetEntry() const
Get entry pointed to by the mouse.
Definition: TLegend.cxx:426
Storage class for one entry of a TLegend.
Definition: TLegendEntry.h:44
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:80
Float_t GetColumnSeparation() const
Definition: TLegend.h:57
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:31
static const double x2[5]
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 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
char * out
Definition: TBase64.cxx:29
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
Float_t GetMargin() const
Definition: TLegend.h:62
void SetNColumns(Int_t nColumns)
Set the number of columns for the legend.
Definition: TLegend.cxx:538
Float_t fColumnSeparation
Definition: TLegend.h:90
Text Attributes class.
Definition: TAttText.h:32
virtual const char * GetHeader() const
Returns the header, which is the title that appears at the top of the legend.
Definition: TLegend.cxx:467
Float_t GetEntrySeparation() const
Definition: TLegend.h:59
Float_t fEntrySeparation
Definition: TLegend.h:85
void SetEntrySeparation(Float_t entryseparation)
Definition: TLegend.h:77
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
#define name(a, b)
Definition: linkTestLib0.cpp:5
Mother of all ROOT objects.
Definition: TObject.h:58
void SetDefaults()
Definition: TLegend.h:72
TList * fPrimitives
Definition: TLegend.h:84
Float_t fMargin
Definition: TLegend.h:88
virtual ~TLegend()
Default destructor.
Definition: TLegend.cxx:261
virtual void SetHeader(const char *header="")
Sets the header, which is the "title" that appears at the top of the legend.
Definition: TLegend.cxx:906
void SetColumnSeparation(Float_t columnSeparation)
Definition: TLegend.h:73
virtual void Paint(Option_t *option="")
Paint this legend with its current attributes.
Definition: TLegend.cxx:508
virtual void Print(Option_t *option="") const
Dump this TLegend and its contents.
Definition: TLegend.cxx:835
TObject * obj
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