]> git.lyx.org Git - lyx.git/blob - src/Layout.h
typo
[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 Lexer;
28 class TextClass;
29
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
36  */
37
38
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.
44  *
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!
47  */
48
49 ///
50 class Layout {
51 public:
52         ///
53         Layout();
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 &);
60         ///
61         void readAlign(Lexer &);
62         ///
63         void readAlignPossible(Lexer &);
64         ///
65         void readLabelType(Lexer &);
66         ///
67         void readEndLabelType(Lexer &);
68         ///
69         void readMargin(Lexer &);
70         ///
71         void readLatexType(Lexer &);
72         ///
73         void readSpacing(Lexer &);
74         ///
75         docstring const & name() const;
76         ///
77         void setName(docstring const & n);
78         ///
79         docstring const & obsoleted_by() const;
80         ///
81         docstring const & depends_on() const;
82         ///
83         std::string const & latexname() const { return latexname_; }
84         ///
85         docstring const & labelstring() const { return labelstring_; }
86         ///
87         docstring const & endlabelstring() const { return endlabelstring_; }
88         ///
89         docstring const & category() const { return category_; }
90         ///
91         docstring const & preamble() const { return preamble_; }
92         ///
93         std::set<std::string> const & requires() const { return requires_; }
94         ///
95         std::string const & latexparam() const { return latexparam_; }
96         ///
97         std::string const & innertag() const { return innertag_; }
98         ///
99         std::string const & labeltag() const { return labeltag_; }
100         ///
101         std::string const & itemtag() const { return itemtag_; }
102         ///
103         docstring const & labelstring_appendix() const {
104                 return labelstring_appendix_;
105         }
106         ///
107         bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
108         ///
109         bool isCommand() const { return latextype == LATEX_COMMAND; }
110         ///
111         bool isEnvironment() const {
112                 return latextype == LATEX_ENVIRONMENT
113                         || latextype == LATEX_BIB_ENVIRONMENT
114                         || latextype == LATEX_ITEM_ENVIRONMENT
115                         || latextype == LATEX_LIST_ENVIRONMENT;
116         }
117
118         ///
119         bool operator==(Layout const &) const;
120         ///
121         bool operator!=(Layout const & rhs) const 
122                 { return !(*this == rhs); }
123
124         ////////////////////////////////////////////////////////////////
125         // members
126         ////////////////////////////////////////////////////////////////
127         /** Is this layout the default layout for an unknown layout? If
128          * so, its name will be displayed as xxx (unknown).
129          */
130         bool unknown_;
131
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.
139         */
140         FontInfo font;
141
142         /** Default font for labels.
143             Interpretation the same as for font above
144         */
145         FontInfo labelfont;
146
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.
150         */
151         FontInfo resfont;
152
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.
156         */
157         FontInfo reslabelfont;
158
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
164         docstring labelsep;
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
168         docstring parindent;
169         ///
170         double parskip;
171         ///
172         double itemsep;
173         ///
174         double topsep;
175         ///
176         double bottomsep;
177         ///
178         double labelbottomsep;
179         ///
180         double parsep;
181         ///
182         Spacing spacing;
183         ///
184         LyXAlignment align;
185         ///
186         LyXAlignment alignpossible;
187         ///
188         LabelType labeltype;
189         ///
190         EndLabelType endlabeltype;
191         ///
192         MarginType margintype;
193         ///
194         bool fill_top;
195         ///
196         bool fill_bottom;
197         ///
198         bool newline_allowed;
199         ///
200         bool nextnoindent;
201         ///
202         bool free_spacing;
203         ///
204         bool pass_thru;
205         /// show this in toc
206         int toclevel;
207         /// special value of toclevel for non-section layouts
208         static const int NOT_IN_TOC;
209
210         /** true when the fragile commands in the paragraph need to be
211             \protect'ed. */
212         bool needprotect;
213         /// true when empty paragraphs should be kept.
214         bool keepempty;
215         /// Type of LaTeX object
216         LatexType latextype;
217         /// Does this object belong in the title part of the document?
218         bool intitle;
219         /// Does this layout allow for an optional parameter?
220         int optionalargs;
221         /// Which counter to step
222         docstring counter;
223         /// Depth of XML command
224         int commanddepth;
225
226         /// Return a pointer on a new layout suitable to describe a caption.
227         /// FIXME: remove this eventually. This is only for tex2lyx
228         /// until it has proper support for the caption inset (JMarc)
229         static Layout * forCaption();
230
231         /// Name of the layout/paragraph environment
232         docstring name_;
233         /// LaTeX name for environment
234         std::string latexname_;
235
236 private:
237         /** Name of an layout that has replaced this layout.
238             This is used to rename a layout, while keeping backward
239             compatibility
240         */
241         docstring obsoleted_by_;
242
243         /** Name of an layout which preamble must come before this one
244             This is used when the preamble snippet uses macros defined in
245             another preamble
246          */
247         docstring depends_on_;
248
249         /// Label string. "Abstract", "Reference", "Caption"...
250         docstring labelstring_;
251         ///
252         docstring endlabelstring_;
253         /// Label string inside appendix. "Appendix", ...
254         docstring labelstring_appendix_;
255         /// LaTeX parameter for environment
256         std::string latexparam_;
257         /// Internal tag to use (e.g., <title></title> for sect header)
258         std::string innertag_;
259         /// Internal tag to use e.g. to surround varlistentry label)
260         std::string labeltag_;
261         /// Internal tag to surround the item text in a list)
262         std::string itemtag_;
263         /// This is the `category' for this layout. The following are
264         /// recommended basic categories: FrontMatter, BackMatter, MainText,
265         /// Section, Starred, List, Theorem.
266         docstring category_;
267         /// Macro definitions needed for this layout
268         docstring preamble_;
269         /// Packages needed for this layout
270         std::set<std::string> requires_;
271 };
272
273 } // namespace lyx
274
275 #endif