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 /// is this layout a default layout created for an unknown layout
55 bool isUnknown() const { return unknown_; }
56 void setUnknown(bool unknown) { unknown_ = unknown; }
57 /// Reads a layout definition from file
58 /// \return true on success.
59 bool read(Lexer &, TextClass const &);
61 void readAlign(Lexer &);
63 void readAlignPossible(Lexer &);
65 void readLabelType(Lexer &);
67 void readEndLabelType(Lexer &);
69 void readMargin(Lexer &);
71 void readLatexType(Lexer &);
73 void readSpacing(Lexer &);
75 docstring const & name() const;
77 void setName(docstring const & n);
79 docstring const & obsoleted_by() const;
81 docstring const & depends_on() const;
83 std::string const & latexname() const { return latexname_; }
85 docstring const & labelstring() const { return labelstring_; }
87 docstring const & endlabelstring() const { return endlabelstring_; }
89 docstring const & category() const { return category_; }
91 docstring const & preamble() const { return preamble_; }
93 std::set<std::string> const & requires() const { return requires_; }
95 std::string const & latexparam() const { return latexparam_; }
97 std::string const & innertag() const { return innertag_; }
99 std::string const & labeltag() const { return labeltag_; }
101 std::string const & itemtag() const { return itemtag_; }
103 docstring const & labelstring_appendix() const {
104 return labelstring_appendix_;
107 bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
109 bool isCommand() const { return latextype == LATEX_COMMAND; }
111 bool isEnvironment() const {
112 return latextype == LATEX_ENVIRONMENT
113 || latextype == LATEX_BIB_ENVIRONMENT
114 || latextype == LATEX_ITEM_ENVIRONMENT
115 || latextype == LATEX_LIST_ENVIRONMENT;
119 bool operator==(Layout const &) const;
121 bool operator!=(Layout const & rhs) const
122 { return !(*this == rhs); }
124 ////////////////////////////////////////////////////////////////
126 ////////////////////////////////////////////////////////////////
127 /** Is this layout the default layout for an unknown layout? If
128 * so, its name will be displayed as xxx (unknown).
132 /** Default font for this layout/environment.
133 The main font for this kind of environment. If an attribute has
134 INHERITED_*, it means that the value is specified by
135 the defaultfont for the entire layout. If we are nested, the
136 font is inherited from the font in the environment one level
137 up until the font is resolved. The values :IGNORE_*
138 and FONT_TOGGLE are illegal here.
142 /** Default font for labels.
143 Interpretation the same as for font above
147 /** Resolved version of the font for this layout/environment.
148 This is a resolved version the default font. The font is resolved
149 against the defaultfont of the entire layout.
153 /** Resolved version of the font used for labels.
154 This is a resolved version the label font. The font is resolved
155 against the defaultfont of the entire layout.
157 FontInfo reslabelfont;
159 /// Text that dictates how wide the left margin is on the screen
160 docstring leftmargin;
161 /// Text that dictates how wide the right margin is on the screen
162 docstring rightmargin;
163 /// Text that dictates how much space to leave after a potential label
165 /// Text that dictates how much space to leave before a potential label
166 docstring labelindent;
167 /// Text that dictates the width of the indentation of indented pars
178 double labelbottomsep;
186 LyXAlignment alignpossible;
190 EndLabelType endlabeltype;
192 MarginType margintype;
198 bool newline_allowed;
207 /// special value of toclevel for non-section layouts
208 static const int NOT_IN_TOC;
209 /// for new environment insets
210 std::string latexheader;
211 /// for new environment insets
212 std::string latexfooter;
213 /// for new environment insets
214 std::string latexparagraph;
216 /** true when the fragile commands in the paragraph need to be
219 /// true when empty paragraphs should be kept.
221 /// Type of LaTeX object
223 /// Does this object belong in the title part of the document?
225 /// Does this layout allow for an optional parameter?
227 /// Which counter to step
229 /// Depth of XML command
232 /// Return a pointer on a new layout suitable to describe a caption.
233 /// FIXME: remove this eventually. This is only for tex2lyx
234 /// until it has proper support for the caption inset (JMarc)
235 static Layout * forCaption();
237 /// Name of the layout/paragraph environment
239 /// LaTeX name for environment
240 std::string latexname_;
243 /** Name of an layout that has replaced this layout.
244 This is used to rename a layout, while keeping backward
247 docstring obsoleted_by_;
249 /** Name of an layout which preamble must come before this one
250 This is used when the preamble snippet uses macros defined in
253 docstring depends_on_;
255 /// Label string. "Abstract", "Reference", "Caption"...
256 docstring labelstring_;
258 docstring endlabelstring_;
259 /// Label string inside appendix. "Appendix", ...
260 docstring labelstring_appendix_;
261 /// LaTeX parameter for environment
262 std::string latexparam_;
263 /// Internal tag to use (e.g., <title></title> for sect header)
264 std::string innertag_;
265 /// Internal tag to use e.g. to surround varlistentry label)
266 std::string labeltag_;
267 /// Internal tag to surround the item text in a list)
268 std::string itemtag_;
269 /// This is the `category' for this layout. The following are
270 /// recommended basic categories: FrontMatter, BackMatter, MainText,
271 /// Section, Starred, List, Theorem.
273 /// Macro definitions needed for this layout
275 /// Packages needed for this layout
276 std::set<std::string> requires_;