]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLayout.h
2ef6be4fdfb30f4a47dde10ebdcb9c7d6dbdf227
[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 const & latexargs() const { return latexargs_; }
90         ///
91         Layout::LaTeXArgMap const & postcommandargs() const { return postcommandargs_; }
92         /// Returns latexargs() + postcommandargs().
93         /// But note that it returns a *copy*, not a reference, so do not do 
94         /// anything like:
95         ///   Layout::LaTeXArgMap::iterator it = args().begin();
96         ///   Layout::LaTeXArgMap::iterator en = args().end();
97         /// Those are iterators for different containers.
98         Layout::LaTeXArgMap args() const;
99         ///
100         unsigned int optArgs() const;
101         ///
102         unsigned int requiredArgs() const;
103         ///
104         docstring preamble() const { return preamble_; }
105         /// Get language dependent macro definitions needed for this inset
106         docstring const langpreamble() const { return langpreamble_; }
107         /// Get language and babel dependent macro definitions needed for
108         /// this inset
109         docstring const babelpreamble() const { return babelpreamble_; }
110         ///
111         docstring counter() const { return counter_; }
112         ///
113         docstring refprefix() const { return refprefix_; }
114         /// The tag enclosing all the material in this inset. Default is "span".
115         std::string const & htmltag() const;
116         /// Additional attributes for inclusion with the start tag. Default (if
117         /// a tag is provided) is: class="name".
118         std::string const & htmlattr() const;
119         /// Tag for individual paragraphs in the inset. Default is none.
120         std::string const & htmlinnertag() const { return htmlinnertag_; }
121         /// Attributes for that tag. Default (if a tag is provided) is: 
122         /// class="name_inner".
123         std::string const & htmlinnerattr() const;
124         /// A label for this environment, possibly including a reference
125         /// to a counter. E.g., for footnote, it might be:
126         ///    \arabic{footnote}
127         /// No default.
128         /// FIXME Could we get this from the layout?
129         std::string const & htmllabel() const { return htmllabel_; }
130         ///
131         inline std::string htmllabeltag() const { return "span"; }
132         ///
133         std::string htmllabelattr() const 
134                 { return "class=\"" + defaultCSSClass() + "_label\""; }
135         /// CSS associated with this inset.
136         docstring htmlstyle() const;
137         /// Additional material for the header.
138         docstring htmlpreamble() const { return htmlpreamble_; }
139         /// Whether this inset represents a "block" of material, i.e., a set
140         /// of paragraphs of its own (true), or should be run into the previous
141         /// paragraph (false). Examples:
142         ///   For branches, this is false.
143         ///   For footnotes, this is true.
144         /// Defaults to true.
145         bool htmlisblock() const { return htmlisblock_; }
146         ///
147         std::set<std::string> requires() const { return requires_; }
148         ///
149         bool isMultiPar() const { return multipar_; }
150         ///
151         bool forcePlainLayout() const { return forceplain_; }
152         ///
153         bool allowParagraphCustomization() const { return custompars_; }
154         ///
155         bool isPassThru() const { return passthru_; }
156         ///
157         bool parbreakIsNewline() const { return parbreakisnewline_; }
158         ///
159         bool isNeedProtect() const { return needprotect_; }
160         ///
161         bool isFreeSpacing() const { return freespacing_; }
162         ///
163         bool isKeepEmpty() const { return keepempty_; }
164         ///
165         bool forceLTR() const { return forceltr_; }
166         ///
167         bool forceOwnlines() const { return forceownlines_; }
168         ///
169         bool isInToc() const { return intoc_; }
170         ///
171         bool spellcheck() const { return spellcheck_; }
172         ///
173         bool resetsFont() const { return resetsfont_; }
174         ///
175         bool isDisplay() const { return display_; }
176         ///
177         bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
178 private:
179         ///
180         void makeDefaultCSS() const;
181         ///
182         std::string defaultCSSClass() const;
183         ///
184         void readArgument(Lexer &);
185         ///
186         docstring name_;
187         /**
188                 * This is only used (at present) to decide where to put them on the menus.
189                 * Values are 'charstyle', 'custom' (things that by default look like a
190                 * footnote), 'element' (docbook), 'standard'.
191                 */
192         InsetLyXType lyxtype_;
193         ///
194         docstring labelstring_;
195         ///
196         bool contentaslabel_;
197         ///
198         InsetDecoration decoration_;
199         ///
200         InsetLaTeXType latextype_;
201         ///
202         std::string latexname_;
203         ///
204         std::string latexparam_;
205         ///
206         docstring leftdelim_;
207         ///
208         docstring rightdelim_;
209         ///
210         FontInfo font_;
211         ///
212         FontInfo labelfont_;
213         ///
214         ColorCode bgcolor_;
215         ///
216         docstring counter_;
217         ///
218         docstring preamble_;
219         /// Language dependent macro definitions needed for this inset
220         docstring langpreamble_;
221         /// Language and babel dependent macro definitions needed for this inset
222         docstring babelpreamble_;
223         ///
224         docstring refprefix_;
225         ///
226         mutable std::string htmltag_;
227         ///
228         mutable std::string htmlattr_;
229         ///
230         std::string htmlinnertag_;
231         ///
232         mutable std::string htmlinnerattr_;
233         ///
234         std::string htmllabel_;
235         ///
236         docstring htmlstyle_;
237         /// Cache for default CSS info for this inset.
238         mutable docstring htmldefaultstyle_;
239         /// Cache for default CSS class.
240         mutable std::string defaultcssclass_;
241         /// Whether to force generation of default CSS even if some is given.
242         /// False by default.
243         bool htmlforcecss_;
244         ///
245         docstring htmlpreamble_;
246         ///
247         bool htmlisblock_;
248         ///
249         std::set<std::string> requires_;
250         ///
251         bool multipar_;
252         /// 
253         bool custompars_;
254         ///
255         bool forceplain_;
256         ///
257         bool passthru_;
258         ///
259         bool parbreakisnewline_;
260         ///
261         bool freespacing_;
262         ///
263         bool keepempty_;
264         ///
265         bool forceltr_;
266         ///
267         bool forceownlines_;
268         ///
269         bool needprotect_;
270         /// should the contents be written to TOC strings?
271         bool intoc_;
272         /// check spelling of this inset?
273         bool spellcheck_;
274         ///
275         bool resetsfont_;
276         ///
277         bool display_;
278         ///
279         bool forcelocalfontswitch_;
280         ///
281         Layout::LaTeXArgMap latexargs_;
282         ///
283         Layout::LaTeXArgMap postcommandargs_;
284 };
285
286 ///
287 InsetLayout::InsetLyXType translateLyXType(std::string const & str);
288 InsetLayout::InsetDecoration translateDecoration(std::string const & str);
289
290 } // namespace lyx
291
292 #endif