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.
19 #include "support/docstring.h"
30 /// The different output types
41 /// The different margin types
42 enum LYX_MARGIN_TYPE {
52 MARGIN_RIGHT_ADDRESS_BOX
69 LYX_ALIGN_LAYOUT = 16,
71 LYX_ALIGN_SPECIAL = 32
76 void operator|=(LyXAlignment & la1, LyXAlignment la2) {
77 la1 = static_cast<LyXAlignment>(la1 | la2);
83 LyXAlignment operator|(LyXAlignment la1, LyXAlignment la2) {
84 return static_cast<LyXAlignment>(static_cast<int>(la1) | static_cast<int>(la2));
88 /// The different LaTeX-Types
89 enum LYX_LATEX_TYPES {
97 LATEX_ITEM_ENVIRONMENT,
99 LATEX_BIB_ENVIRONMENT,
101 LATEX_LIST_ENVIRONMENT
105 /// The different title types
106 enum LYX_TITLE_LATEX_TYPES {
108 TITLE_COMMAND_AFTER = 1,
114 /// The different label types
115 enum LYX_LABEL_TYPES {
123 LABEL_TOP_ENVIRONMENT,
125 LABEL_CENTERED_TOP_ENVIRONMENT,
127 // the flushright labels following now must start with LABEL_STATIC
142 enum LYX_END_LABEL_TYPES {
148 END_LABEL_FILLED_BOX,
152 END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
154 END_LABEL_ENUM_LAST = END_LABEL_STATIC
157 /* Fix labels are printed flushright, manual labels flushleft.
158 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
159 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
160 * This seems a funny restriction, but I think other combinations are
161 * not needed, so I will not change it yet.
162 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
166 /* There is a parindent and a parskip. Which one is used depends on the
167 * paragraph_separation-flag of the text-object.
168 * BUT: parindent is only thrown away, if a parskip is defined! So if you
169 * want a space between the paragraphs and a parindent at the same time,
170 * you should set parskip to zero and use topsep, parsep and bottomsep.
172 * The standard layout is an exception: its parindent is only set, if the
173 * previous paragraph is standard too. Well, this is LateX and it is good!
182 bool read(Lexer &, TextClass const &);
184 void readAlign(Lexer &);
186 void readAlignPossible(Lexer &);
188 void readLabelType(Lexer &);
190 void readEndLabelType(Lexer &);
192 void readMargin(Lexer &);
194 void readLatexType(Lexer &);
196 void readSpacing(Lexer &);
198 docstring const & name() const;
200 void setName(docstring const & n);
202 docstring const & obsoleted_by() const;
204 docstring const & depends_on() const;
206 std::string const & latexname() const { return latexname_; }
208 lyx::docstring const & labelstring() const { return labelstring_; }
210 lyx::docstring const & endlabelstring() const { return endlabelstring_; }
212 docstring const & preamble() const { return preamble_; }
214 std::string const & latexparam() const { return latexparam_; }
216 std::string const & innertag() const { return innertag_; }
218 std::string const & labeltag() const { return labeltag_; }
220 std::string const & itemtag() const { return itemtag_; }
222 lyx::docstring const & labelstring_appendix() const {
223 return labelstring_appendix_;
225 /** Default font for this layout/environment.
226 The main font for this kind of environment. If an attribute has
227 Font::INHERITED_*, it means that the value is specified by
228 the defaultfont for the entire layout. If we are nested, the
229 font is inherited from the font in the environment one level
230 up until the font is resolved. The values Font::IGNORE_*
231 and Font::TOGGLE are illegal here.
235 /** Default font for labels.
236 Interpretation the same as for font above
240 /** Resolved version of the font for this layout/environment.
241 This is a resolved version the default font. The font is resolved
242 against the defaultfont of the entire layout.
246 /** Resolved version of the font used for labels.
247 This is a resolved version the label font. The font is resolved
248 against the defaultfont of the entire layout.
252 /// Text that dictates how wide the left margin is on the screen
253 std::string leftmargin;
254 /// Text that dictates how wide the right margin is on the screen
255 std::string rightmargin;
256 /// Text that dictates how much space to leave after a potential label
257 std::string labelsep;
258 /// Text that dictates how much space to leave before a potential label
259 std::string labelindent;
260 /// Text that dictates the width of the indentation of indented pars
261 std::string parindent;
271 double labelbottomsep;
279 LyXAlignment alignpossible;
281 LYX_LABEL_TYPES labeltype;
283 LYX_END_LABEL_TYPES endlabeltype;
285 LYX_MARGIN_TYPE margintype;
291 bool newline_allowed;
299 * Whether this layout was declared with "Environment xxx" as opposed
300 * to "Style xxx". This is part of some unfinished generic environment
301 * handling (see also InsetEnvironment) started by Andre. No layout
302 * that is shipped with LyX has this flag set.
303 * Don't confuse this with isEnvironment()!
308 /// special value of toclevel for non-section layouts
309 static const int NOT_IN_TOC;
310 /// for new environment insets
311 std::string latexheader;
312 /// for new environment insets
313 std::string latexfooter;
314 /// for new environment insets
315 std::string latexparagraph;
317 /** true when the fragile commands in the paragraph need to be
320 /// true when empty paragraphs should be kept.
323 bool isParagraph() const {
324 return latextype == LATEX_PARAGRAPH;
327 bool isCommand() const {
328 return latextype == LATEX_COMMAND;
331 bool isEnvironment() const {
332 return (latextype == LATEX_ENVIRONMENT
333 || latextype == LATEX_BIB_ENVIRONMENT
334 || latextype == LATEX_ITEM_ENVIRONMENT
335 || latextype == LATEX_LIST_ENVIRONMENT);
337 /// Type of LaTeX object
338 LYX_LATEX_TYPES latextype;
339 /// Does this object belong in the title part of the document?
341 /// Does this layout allow for an optional parameter?
343 /// Which counter to step
344 lyx::docstring counter;
345 /// Depth of XML command
348 /// Return a pointer on a new layout suitable to describe a caption.
349 /// FIXME: remove this eventually. This is only for tex2lyx
350 /// until it has proper support for the caption inset (JMarc)
351 static Layout * forCaption();
354 /// Name of the layout/paragraph environment
357 /** Name of an layout that has replaced this layout.
358 This is used to rename a layout, while keeping backward
361 docstring obsoleted_by_;
363 /** Name of an layout which preamble must come before this one
364 This is used when the preamble snippet uses macros defined in
367 docstring depends_on_;
369 /// LaTeX name for environment
370 std::string latexname_;
371 /// Label string. "Abstract", "Reference", "Caption"...
372 lyx::docstring labelstring_;
374 lyx::docstring endlabelstring_;
375 /// Label string inside appendix. "Appendix", ...
376 lyx::docstring labelstring_appendix_;
377 /// LaTeX parameter for environment
378 std::string latexparam_;
379 /// Internal tag to use (e.g., <title></title> for sect header)
380 std::string innertag_;
381 /// Internal tag to use e.g. to surround varlistentry label)
382 std::string labeltag_;
383 /// Internal tag to surround the item text in a list)
384 std::string itemtag_;
385 /// Macro definitions needed for this layout