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();
42   	   TLegend( Double_t x1, Double_t y1, Double_t x2, Double_t y2,
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();
57   	   Float_t         GetColumnSeparation() const { return fColumnSeparation; }
58   	   TLegendEntry   *GetEntry() const;
59   	   Float_t         GetEntrySeparation() const { return fEntrySeparation; }
60   	   virtual const char *GetHeader() const;
61   	   TList          *GetListOfPrimitives() const {return fPrimitives;}
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(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
97