]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLayout.h
04c5cceb68cdd9187974b7b2ee12c338c6510903
[lyx.git] / src / insets / InsetLayout.h
1 // -*- C++ -*-
2 /**
3  * \file InsetLayout.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Martin Vermeer
8  * \author Richard Heck
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef INSET_LAYOUT_H
14 #define INSET_LAYOUT_H
15
16 #include "ColorCode.h"
17 #include "FontInfo.h"
18
19 #include "support/docstring.h"
20 #include "support/debug.h"
21
22 #include <set>
23 #include <string>
24
25 namespace lyx {
26
27 class Lexer;
28 class TextClass;
29
30 ///
31 class InsetLayout {
32 public:
33         // just so these can be put in containers
34         // it should not really be used
35         InsetLayout();
36         ///
37         InsetLayout(docstring const & name);
38         ///
39         enum InsetDecoration {
40                 CLASSIC,
41                 MINIMALISTIC,
42                 CONGLOMERATE,
43                 DEFAULT
44         };
45         ///
46         enum InsetLyXType {
47                 NOLYXTYPE,
48                 CHARSTYLE,
49                 CUSTOM,
50                 ELEMENT,
51                 END,
52                 STANDARD
53         };
54         ///
55         enum InsetLaTeXType {
56                 NOLATEXTYPE,
57                 COMMAND,
58                 ENVIRONMENT,
59                 ILT_ERROR
60         };
61         ///
62         bool read(Lexer & lexrc, TextClass const & tclass);
63         ///
64         docstring name() const { return name_; }
65         ///
66         InsetLyXType lyxtype() const { return lyxtype_; }
67         ///
68         docstring labelstring() const { return labelstring_; }
69         ///
70         bool contentaslabel() const { return contentaslabel_; }
71         ///
72         InsetDecoration decoration() const { return decoration_; }
73         ///
74         InsetLaTeXType latextype() const { return latextype_; }
75         ///
76         std::string latexname() const { return latexname_; }
77         ///
78         std::string latexparam() const { return latexparam_; }
79         ///
80         FontInfo font() const { return font_; }
81         ///
82         FontInfo labelfont() const { return labelfont_; }
83         ///
84         ColorCode bgcolor() const { return bgcolor_; }
85         ///
86         docstring preamble() const { return preamble_; }
87         ///
88         docstring counter() const { return counter_; }
89         ///
90         std::string const & htmltag() const;
91         /// 
92         std::string const & htmlattr() const;
93         /// 
94         std::string const & htmlinnertag() const { return htmlinnertag_; }
95         /// 
96         std::string const & htmlinnerattr() const;
97         ///
98         std::string const & htmllabel() const { return htmllabel_; }
99         ///
100         inline std::string htmllabeltag() const { return "span"; }
101         ///
102         std::string htmllabelattr() const 
103                 { return "class=\"" + defaultCSSClass() + "_label\""; }
104         /// 
105         docstring htmlstyle() const;
106         /// 
107         docstring htmlpreamble() const { return htmlpreamble_; }
108         ///
109         bool htmlisblock() const { return htmlisblock_; }
110         ///
111         std::set<std::string> requires() const { return requires_; }
112         ///
113         bool isMultiPar() const { return multipar_; }
114         ///
115         bool forcePlainLayout() const { return forceplain_; }
116         ///
117         bool allowParagraphCustomization() const { return custompars_; }
118         ///
119         bool isPassThru() const { return passthru_; }
120         ///
121         bool isNeedProtect() const { return needprotect_; }
122         ///
123         bool isFreeSpacing() const { return freespacing_; }
124         ///
125         bool isKeepEmpty() const { return keepempty_; }
126         ///
127         bool forceLTR() const { return forceltr_; }
128         ///
129         bool isInToc() const { return intoc_; }
130         ///
131 private:
132         ///
133         void makeDefaultCSS() const;
134         ///
135         std::string defaultCSSClass() const;
136         ///
137         std::string defaultCSSLabelClass() const { return defaultCSSClass() + "_label"; }
138         ///
139         docstring name_;
140         /**
141                 * This is only used (at present) to decide where to put them on the menus.
142                 * Values are 'charstyle', 'custom' (things that by default look like a
143                 * footnote), 'element' (docbook), 'standard'.
144                 */
145         InsetLyXType lyxtype_;
146         ///
147         docstring labelstring_;
148         ///
149         bool contentaslabel_;
150         ///
151         InsetDecoration decoration_;
152         ///
153         InsetLaTeXType latextype_;
154         ///
155         std::string latexname_;
156         ///
157         std::string latexparam_;
158         ///
159         FontInfo font_;
160         ///
161         FontInfo labelfont_;
162         ///
163         ColorCode bgcolor_;
164         ///
165         docstring counter_;
166         ///
167         docstring preamble_;
168         /// The tag enclosing all the material in this inset. Default is "span".
169         mutable std::string htmltag_;
170         /// Additional attributes for inclusion with the start tag. Default (if
171         /// a tag is provided) is: class="name".
172         mutable std::string htmlattr_;
173         /// Tag for individual paragraphs in the inset. Default is none.
174         std::string htmlinnertag_;
175         /// Attributes for that tag. Default (if a tag is provided) is: 
176         /// class="name_inner".
177         mutable std::string htmlinnerattr_;
178         /// A label for this environment, possibly including a reference
179         /// to a counter. E.g., for footnote, it might be:
180         ///    \arabic{footnote}
181         /// No default.
182         /// FIXME Could we get this from the layout?
183         std::string htmllabel_;
184         /// CSS associated with this inset.
185         docstring htmlstyle_;
186         /// Cache for default CSS info for this inset.
187         mutable docstring htmldefaultstyle_;
188         /// 
189         mutable std::string defaultcssclass_;
190         /// Whether to force generation of default CSS even if some is given.
191         /// False by default.
192         bool htmlforcecss_;
193         /// Additional material for the header.
194         docstring htmlpreamble_;
195         /// Whether this inset represents a "block" of material, i.e., a set
196         /// of paragraphs of its own (true), or should be run into the previous
197         /// paragraph (false). Examples:
198         ///   For branches, this is false.
199         ///   For footnotes, this is true.
200         /// Defaults to true.
201         bool htmlisblock_;
202         ///
203         std::set<std::string> requires_;
204         ///
205         bool multipar_;
206         /// 
207         bool custompars_;
208         ///
209         bool forceplain_;
210         ///
211         bool passthru_;
212         ///
213         bool needprotect_;
214         ///
215         bool freespacing_;
216         ///
217         bool keepempty_;
218         ///
219         bool forceltr_;
220         /// should the contents be written to TOC strings?
221         bool intoc_;
222 };
223
224 ///
225 InsetLayout::InsetLyXType translateLyXType(std::string const & str);
226
227 } // namespace lyx
228
229 #endif