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