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