ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitAna/Utils/interface/TDocDirective.h
Revision: 1.1
Committed: Tue Aug 11 23:09:27 2009 UTC (15 years, 8 months ago) by loizides
Content type: text/plain
Branch: MAIN
CVS Tags: Mit_032, Mit_031, Mit_025c_branch2, Mit_025c_branch1, Mit_030, Mit_029c, Mit_029b, Mit_030_pre1, Mit_029a, Mit_029, Mit_029_pre1, Mit_028a, Mit_025c_branch0, Mit_028, Mit_027a, Mit_027, Mit_026, Mit_025e, Mit_025d, Mit_025c, Mit_025b, Mit_025a, Mit_025, Mit_025pre2, Mit_024b, Mit_025pre1, Mit_024a, Mit_024, Mit_023, Mit_022a, Mit_022, Mit_020d, TMit_020d, Mit_020c, Mit_021, Mit_021pre2, Mit_021pre1, Mit_020b, Mit_020a, Mit_020, Mit_020pre1, Mit_018, Mit_017, Mit_017pre3, Mit_017pre2, Mit_017pre1, Mit_016, Mit_015b, Mit_015a, Mit_015, Mit_014e, Mit_014d, Mit_014c, Mit_014b, Mit_014a, Mit_014, Mit_014pre3, Mit_014pre2, Mit_014pre1, Mit_013d, Mit_013c, Mit_013b, Mit_013a, Mit_013, Mit_013pre1, Mit_012i, Mit_012h, Mit_012g, Mit_012f, Mit_012e, Mit_012d, Mit_012c, Mit_012b, Mit_012a, Mit_012, Mit_011a, Mit_011, Mit_010a, HEAD
Branch point for: Mit_025c_branch
Log Message:
Added THtml from ROOT

File Contents

# User Rev Content
1 loizides 1.1 // @(#)root/html:$Id: TDocDirective.h 23799 2008-05-12 13:10:34Z axel $
2     // Author: Axel Naumann 2007-01-25
3    
4     /*************************************************************************
5     * Copyright (C) 1995-2007, 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_TDocDirective
13     #define ROOT_TDocDirective
14    
15     ////////////////////////////////////////////////////////////////////////////
16     // //
17     // TDocDirective //
18     // //
19     // Special treatment of comments, like HTML source, a macro, or latex. //
20     // //
21     ////////////////////////////////////////////////////////////////////////////
22    
23     #ifndef ROOT_TNamed
24     #include "TNamed.h"
25     #endif
26    
27    
28     class TClass;
29     class TDocParser;
30     class TDocOutput;
31     class THtml;
32     class TLatex;
33     class TMacro;
34     class TVirtualPad;
35    
36     class TDocDirective: public TNamed {
37     protected:
38     TDocParser* fDocParser; // parser invoking this handler
39     THtml* fHtml; // parser's THtml object
40     TDocOutput* fDocOutput; // parser invoking this handler
41     TString fParameters; // parameters to the directive
42     Int_t fCounter; // counter to generate unique names, -1 to ignore
43    
44     virtual void AddParameter(const TString& /*name*/, const char* /*value*/ = 0) {}
45    
46     TDocDirective() {}
47     TDocDirective(const char* name): TNamed(name, ""), fDocParser(0), fCounter(-1) {};
48     virtual ~TDocDirective() {}
49    
50     const char* GetName() const { return TNamed::GetName(); }
51     void GetName(TString& name) const;
52     TDocParser* GetDocParser() const { return fDocParser; }
53     TDocOutput* GetDocOutput() const { return fDocOutput; }
54     THtml* GetHtml() const { return fHtml; }
55     const char* GetOutputDir() const;
56    
57     void SetParser(TDocParser* parser);
58     void SetParameters(const char* params);
59     void SetTag(const char* tag) { SetTitle(tag); }
60     void SetCounter(Int_t count) { fCounter = count; }
61     virtual void DeleteOutputFiles(const char* ext) const;
62    
63     public:
64     // get the tag ending this directive
65     virtual const char* GetEndTag() const = 0;
66    
67     // add a line to the directive's text
68     virtual void AddLine(const TSubString& line) = 0;
69    
70     // retrieve the result (replacement) of the directive; return false if invalid
71     virtual Bool_t GetResult(TString& result) = 0;
72    
73     // Delete output for the parser's current class or module.
74     virtual void DeleteOutput() const {}
75    
76     friend class TDocParser;
77    
78     ClassDef(TDocDirective, 0); // THtml directive handler
79     };
80    
81     class TDocHtmlDirective: public TDocDirective {
82     private:
83     TString fText; // HTML text to be kept
84     Bool_t fVerbatim; // whether we are in a <pre></pre> block
85     public:
86     TDocHtmlDirective(): TDocDirective("HTML"), fVerbatim(kFALSE) {}
87     virtual ~TDocHtmlDirective() {}
88    
89     virtual void AddLine(const TSubString& line);
90     virtual const char* GetEndTag() const { return "end_html"; }
91     virtual Bool_t GetResult(TString& result);
92    
93     ClassDef(TDocHtmlDirective, 0); // Handler for "Begin_Html"/"End_Html" for raw HTML in documentation comments
94     };
95    
96     class TDocMacroDirective: public TDocDirective {
97     private:
98     TMacro* fMacro; // macro to be executed
99     Bool_t fNeedGraphics; // if set, we cannot switch to batch mode
100     Bool_t fShowSource; // whether a source tab should be created
101     Bool_t fIsFilename; // whether the directive is a failename to be executed
102    
103     virtual void AddParameter(const TString& name, const char* value = 0);
104    
105     public:
106     TDocMacroDirective():
107     TDocDirective("MACRO"), fMacro(0), fNeedGraphics(kFALSE),
108     fShowSource(kFALSE), fIsFilename(kTRUE) {};
109     virtual ~TDocMacroDirective();
110    
111     virtual void AddLine(const TSubString& line);
112     virtual const char* GetEndTag() const { return "end_macro"; }
113     virtual Bool_t GetResult(TString& result);
114     // Delete output for the parser's current class or module.
115     virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
116    
117     ClassDef(TDocMacroDirective, 0); // Handler for "Begin_Macro"/"End_Macro" for code that is executed and that can generate an image for documentation
118     };
119    
120     class TDocLatexDirective: public TDocDirective {
121     protected:
122     TMacro* fLatex; // collection of lines
123     Int_t fFontSize; // fontsize for current latex block, in pixels
124     TString fSeparator; // column separator, often "="
125     Bool_t fSepIsRegexp; // whether fSeparator is a regexp expression
126     TString fAlignment; // column alignment: 'l' for justify left, 'c' for center, 'r' for right
127     TVirtualPad* fBBCanvas; // canvas for bounding box determination
128    
129     virtual void CreateLatex(const char* filename);
130     virtual void AddParameter(const TString& name, const char* value = 0);
131     virtual void GetBoundingBox(TLatex& latex, const char* text, Float_t& width, Float_t& height);
132    
133     public:
134     TDocLatexDirective():
135     TDocDirective("LATEX"), fLatex(0), fFontSize(16),
136     fSepIsRegexp(kFALSE), fBBCanvas(0) {};
137     virtual ~TDocLatexDirective();
138    
139     virtual void AddLine(const TSubString& line);
140     virtual const char* GetEndTag() const {return "end_latex";}
141    
142     const char* GetAlignment() const {return fAlignment;}
143     const char* GetSeparator() const {return fSeparator;}
144     Bool_t SeparatorIsRegexp() const {return fSepIsRegexp;}
145     Int_t GetFontSize() const {return fFontSize;}
146     TList* GetListOfLines() const;
147    
148     virtual Bool_t GetResult(TString& result);
149     // Delete output for the parser's current class or module.
150     virtual void DeleteOutput() const { DeleteOutputFiles(".gif"); }
151    
152     ClassDef(TDocLatexDirective, 0); // Handler for "Begin_Latex"/"End_Latex" to generate an image from latex
153     };
154    
155     #endif // ROOT_TDocDirective