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