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