]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLayout.h
Get rid of Qt resources
[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                         bool validating = false);
61         ///
62         docstring name() const { return name_; }
63         ///
64         void setName(docstring const & n) { name_ = n; }
65         ///
66         InsetLyXType lyxtype() const { return lyxtype_; }
67         ///
68         docstring labelstring() const { return labelstring_; }
69         ///
70         docstring menustring() const { return menustring_; }
71         ///
72         bool contentaslabel() const { return contentaslabel_; }
73         ///
74         InsetDecoration decoration() const { return decoration_; }
75         ///
76         InsetLaTeXType latextype() const { return latextype_; }
77         ///
78         std::string latexname() const { return latexname_; }
79         ///
80         std::string latexparam() const { return latexparam_; }
81         ///
82         docstring leftdelim() const { return leftdelim_; }
83         ///
84         docstring rightdelim() const { return rightdelim_; }
85         ///
86         FontInfo font() const { return font_; }
87         ///
88         FontInfo labelfont() const { return labelfont_; }
89         ///
90         ColorCode bgcolor() const { return bgcolor_; }
91         ///
92         Layout::LaTeXArgMap const & latexargs() const { return latexargs_; }
93         ///
94         Layout::LaTeXArgMap const & postcommandargs() const { return postcommandargs_; }
95         /// Returns latexargs() + postcommandargs().
96         /// But note that it returns a *copy*, not a reference, so do not do
97         /// anything like:
98         ///   Layout::LaTeXArgMap::iterator it = args().begin();
99         ///   Layout::LaTeXArgMap::iterator en = args().end();
100         /// Those are iterators for different containers.
101         Layout::LaTeXArgMap args() const;
102         ///
103         unsigned int optArgs() const;
104         ///
105         unsigned int requiredArgs() const;
106         ///
107         docstring preamble() const { return preamble_; }
108         /// Get language dependent macro definitions needed for this inset
109         docstring const langpreamble() const { return langpreamble_; }
110         /// Get language and babel dependent macro definitions needed for
111         /// this inset
112         docstring const babelpreamble() const { return babelpreamble_; }
113         ///
114         bool fixedwidthpreambleencoding() const { return fixedwidthpreambleencoding_; }
115         ///
116         docstring counter() const { return counter_; }
117         ///
118         docstring refprefix() const { return refprefix_; }
119         /// The tag enclosing all the material in this inset. Default is "span".
120         std::string const & htmltag() const;
121         /// Additional attributes for inclusion with the start tag. Default (if
122         /// a tag is provided) is: class="name".
123         std::string const & htmlattr() const;
124         /// Tag for individual paragraphs in the inset. Default is none.
125         std::string const & htmlinnertag() const { return htmlinnertag_; }
126         /// Attributes for that tag. Default (if a tag is provided) is:
127         /// class="name_inner".
128         std::string const & htmlinnerattr() const;
129         /// A label for this environment, possibly including a reference
130         /// to a counter. E.g., for footnote, it might be:
131         ///    \arabic{footnote}
132         /// No default.
133         /// FIXME Could we get this from the layout?
134         std::string const & htmllabel() const { return htmllabel_; }
135         ///
136         inline std::string htmllabeltag() const { return "span"; }
137         ///
138         std::string htmllabelattr() const
139                 { return "class=\"" + defaultCSSClass() + "_label\""; }
140         /// CSS associated with this inset.
141         docstring htmlstyle() const;
142         /// Additional material for the header.
143         docstring htmlpreamble() const { return htmlpreamble_; }
144         /// Whether this inset represents a "block" of material, i.e., a set
145         /// of paragraphs of its own (true), or should be run into the previous
146         /// paragraph (false). Examples:
147         ///   For branches, this is false.
148         ///   For footnotes, this is true.
149         /// Defaults to true.
150         bool htmlisblock() const { return htmlisblock_; }
151         ///
152         std::set<std::string> required() const { return required_; }
153         ///
154         bool isMultiPar() const { return multipar_; }
155         ///
156         bool forcePlainLayout() const { return forceplain_; }
157         ///
158         bool allowParagraphCustomization() const { return custompars_; }
159         ///
160         bool isPassThru() const { return passthru_; }
161         ///
162         docstring passThruChars() const { return passthru_chars_; }
163         ///
164         std::string newlineCmd() const { return newline_cmd_; }
165         ///
166         bool parbreakIsNewline() const { return parbreakisnewline_; }
167         ///
168         bool parbreakIgnored() const { return parbreakignored_; }
169         ///
170         bool isNeedProtect() const { return needprotect_; }
171         ///
172         bool needsCProtect() const { return needcprotect_; }
173         /// Protection of some elements such as \ref and \cite
174         /// in \mbox (needed by commands building on soul or ulem)
175         bool isNeedMBoxProtect() const { return needmboxprotect_; }
176         ///
177         bool isFreeSpacing() const { return freespacing_; }
178         ///
179         bool isKeepEmpty() const { return keepempty_; }
180         ///
181         bool forceLTR() const { return forceltr_; }
182         ///
183         bool forceOwnlines() const { return forceownlines_; }
184         ///
185         bool isInToc() const { return intoc_; }
186         ///
187         bool spellcheck() const { return spellcheck_; }
188         ///
189         bool resetsFont() const { return resetsfont_; }
190         ///
191         bool isDisplay() const { return display_; }
192         ///
193         bool forcelocalfontswitch() const { return forcelocalfontswitch_; }
194         ///
195         docstring const & obsoleted_by() const { return obsoleted_by_; }
196         ///
197         bool addToToc() const { return add_to_toc_; }
198         ///
199         std::string tocType() const { return toc_type_; }
200         ///
201         bool isTocCaption() const { return is_toc_caption_; }
202         ///
203         bool editExternally () const { return edit_external_; }
204 private:
205         ///
206         void makeDefaultCSS() const;
207         ///
208         std::string defaultCSSClass() const;
209         ///
210         void readArgument(Lexer &);
211         ///
212         docstring name_;
213         /**
214                 * This is only used (at present) to decide where to put them on the menus.
215                 * Values are 'charstyle', 'custom' (things that by default look like a
216                 * footnote), 'element' (docbook), 'standard'.
217                 */
218         InsetLyXType lyxtype_;
219         ///
220         docstring labelstring_;
221         ///
222         docstring menustring_;
223         ///
224         bool contentaslabel_;
225         ///
226         InsetDecoration decoration_;
227         ///
228         InsetLaTeXType latextype_;
229         ///
230         std::string latexname_;
231         ///
232         std::string latexparam_;
233         ///
234         docstring leftdelim_;
235         ///
236         docstring rightdelim_;
237         ///
238         FontInfo font_;
239         ///
240         FontInfo labelfont_;
241         ///
242         ColorCode bgcolor_;
243         ///
244         docstring counter_;
245         ///
246         docstring preamble_;
247         /// Language dependent macro definitions needed for this inset
248         docstring langpreamble_;
249         /// Language and babel dependent macro definitions needed for this inset
250         docstring babelpreamble_;
251         ///
252         bool fixedwidthpreambleencoding_;
253         ///
254         docstring refprefix_;
255         ///
256         mutable std::string htmltag_;
257         ///
258         mutable std::string htmlattr_;
259         ///
260         std::string htmlinnertag_;
261         ///
262         mutable std::string htmlinnerattr_;
263         ///
264         std::string htmllabel_;
265         ///
266         docstring htmlstyle_;
267         /// Cache for default CSS info for this inset.
268         mutable docstring htmldefaultstyle_;
269         /// Cache for default CSS class.
270         mutable std::string defaultcssclass_;
271         /// Whether to force generation of default CSS even if some is given.
272         /// False by default.
273         bool htmlforcecss_;
274         ///
275         docstring htmlpreamble_;
276         ///
277         bool htmlisblock_;
278         ///
279         std::set<std::string> required_;
280         ///
281         bool multipar_;
282         ///
283         bool custompars_;
284         ///
285         bool forceplain_;
286         ///
287         bool passthru_;
288         ///
289         docstring passthru_chars_;
290         ///
291         std::string newline_cmd_;
292         ///
293         bool parbreakisnewline_;
294         ///
295         bool parbreakignored_;
296         ///
297         bool freespacing_;
298         ///
299         bool keepempty_;
300         ///
301         bool forceltr_;
302         ///
303         bool forceownlines_;
304         ///
305         bool needprotect_;
306         ///
307         bool needcprotect_;
308         ///
309         bool needmboxprotect_;
310         /// should the contents be written to TOC strings?
311         bool intoc_;
312         /// check spelling of this inset?
313         bool spellcheck_;
314         ///
315         bool resetsfont_;
316         ///
317         bool display_;
318         ///
319         bool forcelocalfontswitch_;
320         /** Name of an insetlayout that has replaced this insetlayout.
321             This is used to rename an insetlayout, while keeping backward
322             compatibility
323         */
324         docstring obsoleted_by_;
325         ///
326         Layout::LaTeXArgMap latexargs_;
327         ///
328         Layout::LaTeXArgMap postcommandargs_;
329         ///
330         bool add_to_toc_;
331         ///
332         std::string toc_type_;
333         ///
334         bool is_toc_caption_;
335         ///
336         bool edit_external_;
337 };
338
339 ///
340 InsetLayout::InsetLyXType translateLyXType(std::string const & str);
341 InsetLayout::InsetDecoration translateDecoration(std::string const & str);
342
343 } // namespace lyx
344
345 #endif