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"
30 /* Fix labels are printed flushright, manual labels flushleft.
31 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
32 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
33 * This seems a funny restriction, but I think other combinations are
34 * not needed, so I will not change it yet.
35 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
39 /* There is a parindent and a parskip. Which one is used depends on the
40 * paragraph_separation-flag of the text-object.
41 * BUT: parindent is only thrown away, if a parskip is defined! So if you
42 * want a space between the paragraphs and a parindent at the same time,
43 * you should set parskip to zero and use topsep, parsep and bottomsep.
45 * The standard layout is an exception: its parindent is only set, if the
46 * previous paragraph is standard too. Well, this is LateX and it is good!
54 /// Reads a layout definition from file
55 /// \return true on success.
56 bool read(Lexer &, TextClass const &);
58 void readAlign(Lexer &);
60 void readAlignPossible(Lexer &);
62 void readLabelType(Lexer &);
64 void readEndLabelType(Lexer &);
66 void readMargin(Lexer &);
68 void readLatexType(Lexer &);
70 void readSpacing(Lexer &);
72 docstring const & name() const;
74 void setName(docstring const & n);
76 docstring const & obsoleted_by() const;
78 docstring const & depends_on() const;
80 std::string const & latexname() const { return latexname_; }
82 docstring const & labelstring() const { return labelstring_; }
84 docstring const & endlabelstring() const { return endlabelstring_; }
86 docstring const & category() const { return category_; }
88 docstring const & preamble() const { return preamble_; }
90 std::set<std::string> const & requires() const { return requires_; }
92 std::string const & latexparam() const { return latexparam_; }
94 std::string const & innertag() const { return innertag_; }
96 std::string const & labeltag() const { return labeltag_; }
98 std::string const & itemtag() const { return itemtag_; }
100 docstring const & labelstring_appendix() const {
101 return labelstring_appendix_;
104 bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
106 bool isCommand() const { return latextype == LATEX_COMMAND; }
108 bool isEnvironment() const {
109 return latextype == LATEX_ENVIRONMENT
110 || latextype == LATEX_BIB_ENVIRONMENT
111 || latextype == LATEX_ITEM_ENVIRONMENT
112 || latextype == LATEX_LIST_ENVIRONMENT;
116 bool operator==(Layout const &) const;
118 bool operator!=(Layout const & rhs) const
119 { return !(*this == rhs); }
121 ////////////////////////////////////////////////////////////////
123 ////////////////////////////////////////////////////////////////
124 /** Default font for this layout/environment.
125 The main font for this kind of environment. If an attribute has
126 INHERITED_*, it means that the value is specified by
127 the defaultfont for the entire layout. If we are nested, the
128 font is inherited from the font in the environment one level
129 up until the font is resolved. The values :IGNORE_*
130 and FONT_TOGGLE are illegal here.
134 /** Default font for labels.
135 Interpretation the same as for font above
139 /** Resolved version of the font for this layout/environment.
140 This is a resolved version the default font. The font is resolved
141 against the defaultfont of the entire layout.
145 /** Resolved version of the font used for labels.
146 This is a resolved version the label font. The font is resolved
147 against the defaultfont of the entire layout.
149 FontInfo reslabelfont;
151 /// Text that dictates how wide the left margin is on the screen
152 docstring leftmargin;
153 /// Text that dictates how wide the right margin is on the screen
154 docstring rightmargin;
155 /// Text that dictates how much space to leave after a potential label
157 /// Text that dictates how much space to leave before a potential label
158 docstring labelindent;
159 /// Text that dictates the width of the indentation of indented pars
170 double labelbottomsep;
178 LyXAlignment alignpossible;
182 EndLabelType endlabeltype;
184 MarginType margintype;
190 bool newline_allowed;
199 /// special value of toclevel for non-section layouts
200 static const int NOT_IN_TOC;
201 /// for new environment insets
202 std::string latexheader;
203 /// for new environment insets
204 std::string latexfooter;
205 /// for new environment insets
206 std::string latexparagraph;
208 /** true when the fragile commands in the paragraph need to be
211 /// true when empty paragraphs should be kept.
213 /// Type of LaTeX object
215 /// Does this object belong in the title part of the document?
217 /// Does this layout allow for an optional parameter?
219 /// Which counter to step
221 /// Depth of XML command
224 /// Return a pointer on a new layout suitable to describe a caption.
225 /// FIXME: remove this eventually. This is only for tex2lyx
226 /// until it has proper support for the caption inset (JMarc)
227 static Layout * forCaption();
229 /// Name of the layout/paragraph environment
231 /// LaTeX name for environment
232 std::string latexname_;
235 /** Name of an layout that has replaced this layout.
236 This is used to rename a layout, while keeping backward
239 docstring obsoleted_by_;
241 /** Name of an layout which preamble must come before this one
242 This is used when the preamble snippet uses macros defined in
245 docstring depends_on_;
247 /// Label string. "Abstract", "Reference", "Caption"...
248 docstring labelstring_;
250 docstring endlabelstring_;
251 /// Label string inside appendix. "Appendix", ...
252 docstring labelstring_appendix_;
253 /// LaTeX parameter for environment
254 std::string latexparam_;
255 /// Internal tag to use (e.g., <title></title> for sect header)
256 std::string innertag_;
257 /// Internal tag to use e.g. to surround varlistentry label)
258 std::string labeltag_;
259 /// Internal tag to surround the item text in a list)
260 std::string itemtag_;
261 /// This is the `category' for this layout. The following are
262 /// recommended basic categories: FrontMatter, BackMatter, MainText,
263 /// Section, Starred, List, Theorem.
265 /// Macro definitions needed for this layout
267 /// Packages needed for this layout
268 std::set<std::string> requires_;