]> git.lyx.org Git - lyx.git/blob - src/Layout.h
Replace the PainterInfo::erased_ member by a proper Change object and remove the...
[lyx.git] / src / Layout.h
1 // -*- C++ -*-
2 /**
3  * \file Layout.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  * \author Jean-Marc Lasgouttes
9  * \author André Pönitz
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef LAYOUT_H
15 #define LAYOUT_H
16
17 #include "FontInfo.h"
18 #include "LayoutEnums.h"
19 #include "Spacing.h"
20 #include "support/docstring.h"
21
22 #include <set>
23 #include <string>
24
25 namespace lyx {
26
27 class Language;
28 class Lexer;
29 class TextClass;
30
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
37  */
38
39
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.
45  *
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!
48  */
49
50 ///
51 class Layout {
52 public:
53         ///
54         Layout();
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 &);
61         ///
62         void readAlign(Lexer &);
63         ///
64         void readAlignPossible(Lexer &);
65         ///
66         void readLabelType(Lexer &);
67         ///
68         void readEndLabelType(Lexer &);
69         ///
70         void readMargin(Lexer &);
71         ///
72         void readLatexType(Lexer &);
73         ///
74         void readSpacing(Lexer &);
75         ///
76         docstring const & name() const;
77         ///
78         void setName(docstring const & n);
79         ///
80         docstring const & obsoleted_by() const;
81         ///
82         docstring const & depends_on() const;
83         ///
84         std::string const & latexname() const { return latexname_; }
85         ///
86         docstring const & labelstring() const { return labelstring_; }
87         ///
88         docstring const & endlabelstring() const { return endlabelstring_; }
89         ///
90         docstring const & category() const { return category_; }
91         ///
92         docstring const & preamble() const { return preamble_; }
93         /// Get language dependent macro definitions needed for this layout
94         /// for language \p lang
95         docstring const i18npreamble(Language const * lang) const;
96         ///
97         std::set<std::string> const & requires() const { return requires_; }
98         ///
99         std::string const & latexparam() const { return latexparam_; }
100         ///
101         std::string const & innertag() const { return innertag_; }
102         ///
103         std::string const & labeltag() const { return labeltag_; }
104         ///
105         std::string const & itemtag() const { return itemtag_; }
106         ///
107         docstring const & labelstring_appendix() const {
108                 return labelstring_appendix_;
109         }
110         ///
111         bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
112         ///
113         bool isCommand() const { return latextype == LATEX_COMMAND; }
114         ///
115         bool isEnvironment() const {
116                 return latextype == LATEX_ENVIRONMENT
117                         || latextype == LATEX_BIB_ENVIRONMENT
118                         || latextype == LATEX_ITEM_ENVIRONMENT
119                         || latextype == LATEX_LIST_ENVIRONMENT;
120         }
121
122         ///
123         bool operator==(Layout const &) const;
124         ///
125         bool operator!=(Layout const & rhs) const 
126                 { return !(*this == rhs); }
127
128         ////////////////////////////////////////////////////////////////
129         // members
130         ////////////////////////////////////////////////////////////////
131         /** Is this layout the default layout for an unknown layout? If
132          * so, its name will be displayed as xxx (unknown).
133          */
134         bool unknown_;
135
136         /** Default font for this layout/environment.
137             The main font for this kind of environment. If an attribute has
138             INHERITED_*, it means that the value is specified by
139             the defaultfont for the entire layout. If we are nested, the
140             font is inherited from the font in the environment one level
141             up until the font is resolved. The values :IGNORE_*
142             and FONT_TOGGLE are illegal here.
143         */
144         FontInfo font;
145
146         /** Default font for labels.
147             Interpretation the same as for font above
148         */
149         FontInfo labelfont;
150
151         /** Resolved version of the font for this layout/environment.
152             This is a resolved version the default font. The font is resolved
153             against the defaultfont of the entire layout.
154         */
155         FontInfo resfont;
156
157         /** Resolved version of the font used for labels.
158             This is a resolved version the label font. The font is resolved
159             against the defaultfont of the entire layout.
160         */
161         FontInfo reslabelfont;
162
163         /// Text that dictates how wide the left margin is on the screen
164         docstring leftmargin;
165         /// Text that dictates how wide the right margin is on the screen
166         docstring rightmargin;
167         /// Text that dictates how much space to leave after a potential label
168         docstring labelsep;
169         /// Text that dictates how much space to leave before a potential label
170         docstring labelindent;
171         /// Text that dictates the width of the indentation of indented pars
172         docstring parindent;
173         ///
174         double parskip;
175         ///
176         double itemsep;
177         ///
178         double topsep;
179         ///
180         double bottomsep;
181         ///
182         double labelbottomsep;
183         ///
184         double parsep;
185         ///
186         Spacing spacing;
187         ///
188         LyXAlignment align;
189         ///
190         LyXAlignment alignpossible;
191         ///
192         LabelType labeltype;
193         ///
194         EndLabelType endlabeltype;
195         ///
196         MarginType margintype;
197         ///
198         bool fill_top;
199         ///
200         bool fill_bottom;
201         ///
202         bool newline_allowed;
203         ///
204         bool nextnoindent;
205         ///
206         bool free_spacing;
207         ///
208         bool pass_thru;
209         /// show this in toc
210         int toclevel;
211         /// special value of toclevel for non-section layouts
212         static const int NOT_IN_TOC;
213
214         /** true when the fragile commands in the paragraph need to be
215             \protect'ed. */
216         bool needprotect;
217         /// true when empty paragraphs should be kept.
218         bool keepempty;
219         /// Type of LaTeX object
220         LatexType latextype;
221         /// Does this object belong in the title part of the document?
222         bool intitle;
223         /// Does this layout allow for an optional parameter?
224         int optionalargs;
225         /// Which counter to step
226         docstring counter;
227         /// Depth of XML command
228         int commanddepth;
229
230         /// Return a pointer on a new layout suitable to describe a caption.
231         /// FIXME: remove this eventually. This is only for tex2lyx
232         /// until it has proper support for the caption inset (JMarc)
233         static Layout * forCaption();
234
235         /// Name of the layout/paragraph environment
236         docstring name_;
237         /// LaTeX name for environment
238         std::string latexname_;
239
240 private:
241         /** Name of an layout that has replaced this layout.
242             This is used to rename a layout, while keeping backward
243             compatibility
244         */
245         docstring obsoleted_by_;
246
247         /** Name of an layout which preamble must come before this one
248             This is used when the preamble snippet uses macros defined in
249             another preamble
250          */
251         docstring depends_on_;
252
253         /// Label string. "Abstract", "Reference", "Caption"...
254         docstring labelstring_;
255         ///
256         docstring endlabelstring_;
257         /// Label string inside appendix. "Appendix", ...
258         docstring labelstring_appendix_;
259         /// LaTeX parameter for environment
260         std::string latexparam_;
261         /// Internal tag to use (e.g., <title></title> for sect header)
262         std::string innertag_;
263         /// Internal tag to use e.g. to surround varlistentry label)
264         std::string labeltag_;
265         /// Internal tag to surround the item text in a list)
266         std::string itemtag_;
267         /// This is the `category' for this layout. The following are
268         /// recommended basic categories: FrontMatter, BackMatter, MainText,
269         /// Section, Starred, List, Theorem.
270         docstring category_;
271         /// Macro definitions needed for this layout
272         docstring preamble_;
273         /// Language dependent macro definitions needed for this layout
274         docstring i18npreamble_;
275         /// Packages needed for this layout
276         std::set<std::string> requires_;
277 };
278
279 } // namespace lyx
280
281 #endif