]> git.lyx.org Git - lyx.git/blob - src/insets/InsetLayout.h
1870f52d12f783fc6563f0b3db26d63a01f82710
[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
19 #include "support/docstring.h"
20
21 #include <set>
22 #include <string>
23
24 namespace lyx {
25
26 class Lexer;
27 class TextClass;
28
29 ///
30 class InsetLayout {
31 public:
32         ///
33         InsetLayout();
34         ///
35         enum InsetDecoration {
36                 CLASSIC,
37                 MINIMALISTIC,
38                 CONGLOMERATE,
39                 DEFAULT
40         };
41         ///
42         enum InsetLyXType {
43                 NOLYXTYPE,
44                 CHARSTYLE,
45                 CUSTOM,
46                 ELEMENT,
47                 END,
48                 STANDARD
49         };
50         ///
51         enum InsetLaTeXType {
52                 NOLATEXTYPE,
53                 COMMAND,
54                 ENVIRONMENT,
55                 ILT_ERROR
56         };
57         ///
58         bool read(Lexer & lexrc, TextClass const & tclass);
59         ///
60         docstring name() const { return name_; }
61         ///
62         void setName(docstring const & n) { name_ = n; }
63         ///
64         InsetLyXType lyxtype() const { return lyxtype_; }
65         ///
66         docstring labelstring() const { return labelstring_; }
67         ///
68         bool contentaslabel() const { return contentaslabel_; }
69         ///
70         InsetDecoration decoration() const { return decoration_; }
71         ///
72         InsetLaTeXType latextype() const { return latextype_; }
73         ///
74         std::string latexname() const { return latexname_; }
75         ///
76         std::string latexparam() const { return latexparam_; }
77         ///
78         FontInfo font() const { return font_; }
79         ///
80         FontInfo labelfont() const { return labelfont_; }
81         ///
82         ColorCode bgcolor() const { return bgcolor_; }
83         ///
84         docstring preamble() const { return preamble_; }
85         ///
86         docstring counter() const { return counter_; }
87         ///
88         std::string const & htmltag() const;
89         /// 
90         std::string const & htmlattr() const;
91         /// 
92         std::string const & htmlinnertag() const { return htmlinnertag_; }
93         /// 
94         std::string const & htmlinnerattr() const;
95         ///
96         std::string const & htmllabel() const { return htmllabel_; }
97         ///
98         inline std::string htmllabeltag() const { return "span"; }
99         ///
100         std::string htmllabelattr() const 
101                 { return "class=\"" + defaultCSSClass() + "_label\""; }
102         /// 
103         docstring htmlstyle() const;
104         /// 
105         docstring htmlpreamble() const { return htmlpreamble_; }
106         ///
107         bool htmlisblock() const { return htmlisblock_; }
108         ///
109         std::set<std::string> requires() const { return requires_; }
110         ///
111         bool isMultiPar() const { return multipar_; }
112         ///
113         bool forcePlainLayout() const { return forceplain_; }
114         ///
115         bool allowParagraphCustomization() const { return custompars_; }
116         ///
117         bool isPassThru() const { return passthru_; }
118         ///
119         bool isNeedProtect() const { return needprotect_; }
120         ///
121         bool isFreeSpacing() const { return freespacing_; }
122         ///
123         bool isKeepEmpty() const { return keepempty_; }
124         ///
125         bool forceLTR() const { return forceltr_; }
126         ///
127         bool isInToc() const { return intoc_; }
128         ///
129 private:
130         ///
131         void makeDefaultCSS() const;
132         ///
133         std::string defaultCSSClass() const;
134         ///
135         std::string defaultCSSLabelClass() const { return defaultCSSClass() + "_label"; }
136         ///
137         docstring name_;
138         /**
139                 * This is only used (at present) to decide where to put them on the menus.
140                 * Values are 'charstyle', 'custom' (things that by default look like a
141                 * footnote), 'element' (docbook), 'standard'.
142                 */
143         InsetLyXType lyxtype_;
144         ///
145         docstring labelstring_;
146         ///
147         bool contentaslabel_;
148         ///
149         InsetDecoration decoration_;
150         ///
151         InsetLaTeXType latextype_;
152         ///
153         std::string latexname_;
154         ///
155         std::string latexparam_;
156         ///
157         FontInfo font_;
158         ///
159         FontInfo labelfont_;
160         ///
161         ColorCode bgcolor_;
162         ///
163         docstring counter_;
164         ///
165         docstring preamble_;
166         /// The tag enclosing all the material in this inset. Default is "span".
167         mutable std::string htmltag_;
168         /// Additional attributes for inclusion with the start tag. Default (if
169         /// a tag is provided) is: class="name".
170         mutable std::string htmlattr_;
171         /// Tag for individual paragraphs in the inset. Default is none.
172         std::string htmlinnertag_;
173         /// Attributes for that tag. Default (if a tag is provided) is: 
174         /// class="name_inner".
175         mutable std::string htmlinnerattr_;
176         /// A label for this environment, possibly including a reference
177         /// to a counter. E.g., for footnote, it might be:
178         ///    \arabic{footnote}
179         /// No default.
180         /// FIXME Could we get this from the layout?
181         std::string htmllabel_;
182         /// CSS associated with this inset.
183         docstring htmlstyle_;
184         /// Cache for default CSS info for this inset.
185         mutable docstring htmldefaultstyle_;
186         /// 
187         mutable std::string defaultcssclass_;
188         /// Whether to force generation of default CSS even if some is given.
189         /// False by default.
190         bool htmlforcecss_;
191         /// Additional material for the header.
192         docstring htmlpreamble_;
193         /// Whether this inset represents a "block" of material, i.e., a set
194         /// of paragraphs of its own (true), or should be run into the previous
195         /// paragraph (false). Examples:
196         ///   For branches, this is false.
197         ///   For footnotes, this is true.
198         /// Defaults to true.
199         bool htmlisblock_;
200         ///
201         std::set<std::string> requires_;
202         ///
203         bool multipar_;
204         /// 
205         bool custompars_;
206         ///
207         bool forceplain_;
208         ///
209         bool passthru_;
210         ///
211         bool needprotect_;
212         ///
213         bool freespacing_;
214         ///
215         bool keepempty_;
216         ///
217         bool forceltr_;
218         /// should the contents be written to TOC strings?
219         bool intoc_;
220 };
221
222 ///
223 InsetLayout::InsetLyXType translateLyXType(std::string const & str);
224
225 } // namespace lyx
226
227 #endif