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