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"
27 /* Fix labels are printed flushright, manual labels flushleft.
28 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
29 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
30 * This seems a funny restriction, but I think other combinations are
31 * not needed, so I will not change it yet.
32 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
36 /* There is a parindent and a parskip. Which one is used depends on the
37 * paragraph_separation-flag of the text-object.
38 * BUT: parindent is only thrown away, if a parskip is defined! So if you
39 * want a space between the paragraphs and a parindent at the same time,
40 * you should set parskip to zero and use topsep, parsep and bottomsep.
42 * The standard layout is an exception: its parindent is only set, if the
43 * previous paragraph is standard too. Well, this is LateX and it is good!
51 /// Reads a layout definition from file
52 bool read(Lexer &, TextClass const &);
54 void readAlign(Lexer &);
56 void readAlignPossible(Lexer &);
58 void readLabelType(Lexer &);
60 void readEndLabelType(Lexer &);
62 void readMargin(Lexer &);
64 void readLatexType(Lexer &);
66 void readSpacing(Lexer &);
68 docstring const & name() const;
70 void setName(docstring const & n);
72 docstring const & obsoleted_by() const;
74 docstring const & depends_on() const;
76 std::string const & latexname() const { return latexname_; }
78 docstring const & labelstring() const { return labelstring_; }
80 docstring const & endlabelstring() const { return endlabelstring_; }
82 docstring const & preamble() const { return preamble_; }
84 std::string const & latexparam() const { return latexparam_; }
86 std::string const & innertag() const { return innertag_; }
88 std::string const & labeltag() const { return labeltag_; }
90 std::string const & itemtag() const { return itemtag_; }
92 docstring const & labelstring_appendix() const {
93 return labelstring_appendix_;
95 /** Default font for this layout/environment.
96 The main font for this kind of environment. If an attribute has
97 INHERITED_*, it means that the value is specified by
98 the defaultfont for the entire layout. If we are nested, the
99 font is inherited from the font in the environment one level
100 up until the font is resolved. The values :IGNORE_*
101 and FONT_TOGGLE are illegal here.
105 /** Default font for labels.
106 Interpretation the same as for font above
110 /** Resolved version of the font for this layout/environment.
111 This is a resolved version the default font. The font is resolved
112 against the defaultfont of the entire layout.
116 /** Resolved version of the font used for labels.
117 This is a resolved version the label font. The font is resolved
118 against the defaultfont of the entire layout.
120 FontInfo reslabelfont;
122 /// Text that dictates how wide the left margin is on the screen
123 docstring leftmargin;
124 /// Text that dictates how wide the right margin is on the screen
125 docstring rightmargin;
126 /// Text that dictates how much space to leave after a potential label
128 /// Text that dictates how much space to leave before a potential label
129 docstring labelindent;
130 /// Text that dictates the width of the indentation of indented pars
141 double labelbottomsep;
149 LyXAlignment alignpossible;
153 EndLabelType endlabeltype;
155 MarginType margintype;
161 bool newline_allowed;
169 * Whether this layout was declared with "Environment xxx" as opposed
170 * to "Style xxx". This is part of some unfinished generic environment
171 * handling (see also InsetEnvironment) started by Andre. No layout
172 * that is shipped with LyX has this flag set.
173 * Don't confuse this with isEnvironment()!
178 /// special value of toclevel for non-section layouts
179 static const int NOT_IN_TOC;
180 /// for new environment insets
181 std::string latexheader;
182 /// for new environment insets
183 std::string latexfooter;
184 /// for new environment insets
185 std::string latexparagraph;
187 /** true when the fragile commands in the paragraph need to be
190 /// true when empty paragraphs should be kept.
193 bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
195 bool isCommand() const { return latextype == LATEX_COMMAND; }
197 bool isEnvironment() const {
198 return latextype == LATEX_ENVIRONMENT
199 || latextype == LATEX_BIB_ENVIRONMENT
200 || latextype == LATEX_ITEM_ENVIRONMENT
201 || latextype == LATEX_LIST_ENVIRONMENT;
203 /// Type of LaTeX object
205 /// Does this object belong in the title part of the document?
207 /// Does this layout allow for an optional parameter?
209 /// Which counter to step
211 /// Depth of XML command
214 /// Return a pointer on a new layout suitable to describe a caption.
215 /// FIXME: remove this eventually. This is only for tex2lyx
216 /// until it has proper support for the caption inset (JMarc)
217 static Layout * forCaption();
220 /// Name of the layout/paragraph environment
223 /** Name of an layout that has replaced this layout.
224 This is used to rename a layout, while keeping backward
227 docstring obsoleted_by_;
229 /** Name of an layout which preamble must come before this one
230 This is used when the preamble snippet uses macros defined in
233 docstring depends_on_;
235 /// LaTeX name for environment
236 std::string latexname_;
237 /// Label string. "Abstract", "Reference", "Caption"...
238 docstring labelstring_;
240 docstring endlabelstring_;
241 /// Label string inside appendix. "Appendix", ...
242 docstring labelstring_appendix_;
243 /// LaTeX parameter for environment
244 std::string latexparam_;
245 /// Internal tag to use (e.g., <title></title> for sect header)
246 std::string innertag_;
247 /// Internal tag to use e.g. to surround varlistentry label)
248 std::string labeltag_;
249 /// Internal tag to surround the item text in a list)
250 std::string itemtag_;
251 /// Macro definitions needed for this layout