4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
11 * Full author contact details are available in file CREDITS.
18 #include "LayoutEnums.h"
20 #include "support/docstring.h"
31 /* Fix labels are printed flushright, manual labels flushleft.
32 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
33 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
34 * This seems a funny restriction, but I think other combinations are
35 * not needed, so I will not change it yet.
36 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
40 /* There is a parindent and a parskip. Which one is used depends on the
41 * paragraph_separation-flag of the text-object.
42 * BUT: parindent is only thrown away, if a parskip is defined! So if you
43 * want a space between the paragraphs and a parindent at the same time,
44 * you should set parskip to zero and use topsep, parsep and bottomsep.
46 * The standard layout is an exception: its parindent is only set, if the
47 * previous paragraph is standard too. Well, this is LateX and it is good!
55 /// is this layout a default layout created for an unknown layout
56 bool isUnknown() const { return unknown_; }
57 void setUnknown(bool unknown) { unknown_ = unknown; }
58 /// Reads a layout definition from file
59 /// \return true on success.
60 bool read(Lexer &, TextClass const &);
62 void readAlign(Lexer &);
64 void readAlignPossible(Lexer &);
66 void readLabelType(Lexer &);
68 void readEndLabelType(Lexer &);
70 void readMargin(Lexer &);
72 void readLatexType(Lexer &);
74 void readSpacing(Lexer &);
76 docstring const & name() const { return name_; };
78 void setName(docstring const & n) { name_ = n; }
80 docstring const & obsoleted_by() const { return obsoleted_by_; }
82 docstring const & depends_on() const { return depends_on_; }
84 std::string const & latexname() const { return latexname_; }
86 void setLatexName(std::string const & n) { latexname_ = n; }
88 docstring const & labelstring() const { return labelstring_; }
90 docstring const & endlabelstring() const { return endlabelstring_; }
92 docstring const & category() const { return category_; }
94 docstring const & preamble() const { return preamble_; }
95 /// Get language dependent macro definitions needed for this layout
96 /// for language \p lang
97 docstring const langpreamble(Language const * lang) const;
98 /// Get language and babel dependent macro definitions needed for
99 /// this layout for language \p lang
100 docstring const babelpreamble(Language const * lang) const;
102 std::set<std::string> const & requires() const { return requires_; }
104 std::string const & latexparam() const { return latexparam_; }
106 std::string const & innertag() const { return innertag_; }
108 std::string const & labeltag() const { return labeltag_; }
110 std::string const & itemtag() const { return itemtag_; }
112 std::string const & htmltag() const { return htmltag_; }
114 std::string const & htmlattr() const { return htmlattr_; }
116 std::string const & htmlitem() const { return htmlitem_; }
118 std::string const & htmlitemattr() const { return htmlitemattr_; }
120 std::string const & htmllabel() const { return htmllabel_; }
122 std::string const & htmllabelattr() const { return htmllabelattr_; }
124 bool htmllabelfirst() const { return htmllabelfirst_; }
126 docstring const & htmlstyle() const { return htmlstyle_; }
128 docstring const & htmlpreamble() const { return htmlpreamble_; }
130 docstring const & labelstring_appendix() const {
131 return labelstring_appendix_;
134 bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
136 bool isCommand() const { return latextype == LATEX_COMMAND; }
138 bool isEnvironment() const {
139 return latextype == LATEX_ENVIRONMENT
140 || latextype == LATEX_BIB_ENVIRONMENT
141 || latextype == LATEX_ITEM_ENVIRONMENT
142 || latextype == LATEX_LIST_ENVIRONMENT;
146 bool operator==(Layout const &) const;
148 bool operator!=(Layout const & rhs) const
149 { return !(*this == rhs); }
151 ////////////////////////////////////////////////////////////////
153 ////////////////////////////////////////////////////////////////
154 /** Default font for this layout/environment.
155 The main font for this kind of environment. If an attribute has
156 INHERITED_*, it means that the value is specified by
157 the defaultfont for the entire layout. If we are nested, the
158 font is inherited from the font in the environment one level
159 up until the font is resolved. The values :IGNORE_*
160 and FONT_TOGGLE are illegal here.
164 /** Default font for labels.
165 Interpretation the same as for font above
169 /** Resolved version of the font for this layout/environment.
170 This is a resolved version the default font. The font is resolved
171 against the defaultfont of the entire layout.
175 /** Resolved version of the font used for labels.
176 This is a resolved version the label font. The font is resolved
177 against the defaultfont of the entire layout.
179 FontInfo reslabelfont;
181 /// Text that dictates how wide the left margin is on the screen
182 docstring leftmargin;
183 /// Text that dictates how wide the right margin is on the screen
184 docstring rightmargin;
185 /// Text that dictates how much space to leave after a potential label
187 /// Text that dictates how much space to leave before a potential label
188 docstring labelindent;
189 /// Text that dictates the width of the indentation of indented pars
200 double labelbottomsep;
208 LyXAlignment alignpossible;
212 EndLabelType endlabeltype;
214 MarginType margintype;
220 bool newline_allowed;
229 /// special value of toclevel for non-section layouts
230 static const int NOT_IN_TOC;
232 /** true when the fragile commands in the paragraph need to be
235 /// true when empty paragraphs should be kept.
237 /// Type of LaTeX object
239 /// Does this object belong in the title part of the document?
241 /// Does this layout allow for an optional parameter?
243 /// Which counter to step
245 /// Depth of XML command
248 /// Return a pointer on a new layout suitable to describe a caption.
249 /// FIXME: remove this eventually. This is only for tex2lyx
250 /// until it has proper support for the caption inset (JMarc)
251 static Layout * forCaption();
255 /// Name of the layout/paragraph environment
258 /// LaTeX name for environment
259 std::string latexname_;
261 /** Is this layout the default layout for an unknown layout? If
262 * so, its name will be displayed as xxx (unknown).
266 /** Name of an layout that has replaced this layout.
267 This is used to rename a layout, while keeping backward
270 docstring obsoleted_by_;
272 /** Name of an layout which preamble must come before this one
273 This is used when the preamble snippet uses macros defined in
276 docstring depends_on_;
278 /// Label string. "Abstract", "Reference", "Caption"...
279 docstring labelstring_;
281 docstring endlabelstring_;
282 /// Label string inside appendix. "Appendix", ...
283 docstring labelstring_appendix_;
284 /// LaTeX parameter for environment
285 std::string latexparam_;
286 /// Internal tag to use (e.g., <title></title> for sect header)
287 std::string innertag_;
288 /// Internal tag to use e.g. to surround varlistentry label)
289 std::string labeltag_;
290 /// Internal tag to surround the item text in a list)
291 std::string itemtag_;
292 /// Tag for HTML output, e.g., h2.
293 std::string htmltag_;
294 /// Additional attributes for inclusion with the start tag,
295 /// e.g.: class='section'.
296 std::string htmlattr_;
297 /// Tag for individual paragraphs in an environment. In lists, this
298 /// would be something like "li". But it also needs to be set for
299 /// quotation, e.g., since the paragraphs in a quote need to be
301 std::string htmlitem_;
302 /// Attributes for htmlitem_
303 std::string htmlitemattr_;
304 /// Tag for labels, of whatever sort. One use for this is in setting
305 /// descriptions, in which case it would be: dt. Another use is to
306 /// customize the display of, say, the auto-generated label for
307 /// sections (in that case, it might be: span).
308 std::string htmllabel_;
309 /// Attributes for the label.
310 std::string htmllabelattr_;
311 /// Whether to put the label before the item, or within the item.
312 /// I.e., do we have (true):
313 /// <label>...</label><item>...</item>
314 /// or instead (false):
315 /// <item><label>...</label>...</item>
316 /// The latter is the default.
317 bool htmllabelfirst_;
318 /// CSS information needed by this layout.
319 docstring htmlstyle_;
320 /// Any other info for the HTML header.
321 docstring htmlpreamble_;
322 /// This is the `category' for this layout. The following are
323 /// recommended basic categories: FrontMatter, BackMatter, MainText,
324 /// Section, Starred, List, Theorem.
326 /// Macro definitions needed for this layout
328 /// Language dependent macro definitions needed for this layout
329 docstring langpreamble_;
330 /// Language and babel dependent macro definitions needed for this layout
331 docstring babelpreamble_;
332 /// Packages needed for this layout
333 std::set<std::string> requires_;