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