]> git.lyx.org Git - lyx.git/blob - src/Layout.h
resolve the layout.h <=> Layout.h conflict
[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 LYX_LAYOUT_H
15 #define LYX_LAYOUT_H
16
17 #include "Font.h"
18 #include "Spacing.h"
19 #include "support/docstring.h"
20
21 #include <string>
22
23
24 namespace lyx {
25
26 class Lexer;
27 class TextClass;
28
29
30 /// The different output types
31 enum OutputType {
32         ///
33         LATEX = 1,
34         ///
35         DOCBOOK,
36         ///
37         LITERATE
38 };
39
40
41 /// The different margin types
42 enum LYX_MARGIN_TYPE {
43         ///
44         MARGIN_MANUAL = 1,
45         ///
46         MARGIN_FIRST_DYNAMIC,
47         ///
48         MARGIN_DYNAMIC,
49         ///
50         MARGIN_STATIC,
51         ///
52         MARGIN_RIGHT_ADDRESS_BOX
53 };
54
55
56 ///
57 enum LyXAlignment {
58         ///
59         LYX_ALIGN_NONE = 0,
60         ///
61         LYX_ALIGN_BLOCK = 1,
62         ///
63         LYX_ALIGN_LEFT = 2,
64         ///
65         LYX_ALIGN_RIGHT = 4,
66         ///
67         LYX_ALIGN_CENTER = 8,
68         ///
69         LYX_ALIGN_LAYOUT = 16,
70         ///
71         LYX_ALIGN_SPECIAL = 32
72 };
73
74 ///
75 inline
76 void operator|=(LyXAlignment & la1, LyXAlignment la2) {
77         la1 = static_cast<LyXAlignment>(la1 | la2);
78 }
79
80
81 /// The different LaTeX-Types
82 enum LYX_LATEX_TYPES {
83         ///
84         LATEX_PARAGRAPH = 1,
85         ///
86         LATEX_COMMAND,
87         ///
88         LATEX_ENVIRONMENT,
89         ///
90         LATEX_ITEM_ENVIRONMENT,
91         ///
92         LATEX_BIB_ENVIRONMENT,
93         ///
94         LATEX_LIST_ENVIRONMENT
95 };
96
97
98 /// The different title types
99 enum LYX_TITLE_LATEX_TYPES {
100         ///
101         TITLE_COMMAND_AFTER = 1,
102         ///
103         TITLE_ENVIRONMENT
104 };
105
106
107 /// The different label types
108 enum LYX_LABEL_TYPES {
109         ///
110         LABEL_NO_LABEL,
111         ///
112         LABEL_MANUAL,
113         ///
114         LABEL_BIBLIO,
115         ///
116         LABEL_TOP_ENVIRONMENT,
117         ///
118         LABEL_CENTERED_TOP_ENVIRONMENT,
119
120         // the flushright labels following now must start with LABEL_STATIC
121         ///
122         LABEL_STATIC,
123         ///
124         LABEL_SENSITIVE,
125         ///
126         LABEL_COUNTER,
127         ///
128         LABEL_ENUMERATE,
129         ///
130         LABEL_ITEMIZE
131 };
132
133
134 ///
135 enum LYX_END_LABEL_TYPES {
136         ///
137         END_LABEL_NO_LABEL,
138         ///
139         END_LABEL_BOX,
140         ///
141         END_LABEL_FILLED_BOX,
142         ///
143         END_LABEL_STATIC,
144         ///
145         END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
146         ///
147         END_LABEL_ENUM_LAST = END_LABEL_STATIC
148 };
149
150 /* Fix labels are printed flushright, manual labels flushleft.
151  * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
152  * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
153  * This seems a funny restriction, but I think other combinations are
154  * not needed, so I will not change it yet.
155  * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
156  */
157
158
159 /* There is a parindent and a parskip. Which one is used depends on the
160  * paragraph_separation-flag of the text-object.
161  * BUT: parindent is only thrown away, if a parskip is defined! So if you
162  * want a space between the paragraphs and a parindent at the same time,
163  * you should set parskip to zero and use topsep, parsep and bottomsep.
164  *
165  * The standard layout is an exception: its parindent is only set, if the
166  * previous paragraph is standard too. Well, this is LateX and it is good!
167  */
168
169 ///
170 class Layout {
171 public:
172         ///
173         Layout();
174         ///
175         bool read(Lexer &, TextClass const &);
176         ///
177         void readAlign(Lexer &);
178         ///
179         void readAlignPossible(Lexer &);
180         ///
181         void readLabelType(Lexer &);
182         ///
183         void readEndLabelType(Lexer &);
184         ///
185         void readMargin(Lexer &);
186         ///
187         void readLatexType(Lexer &);
188         ///
189         void readSpacing(Lexer &);
190         ///
191         std::string const & name() const;
192         ///
193         void setName(std::string const & n);
194         ///
195         std::string const & obsoleted_by() const;
196         ///
197         std::string const & depends_on() const;
198         ///
199         std::string const & latexname() const { return latexname_; }
200         ///
201         lyx::docstring const & labelstring() const { return labelstring_; }
202         ///
203         lyx::docstring const & endlabelstring() const { return endlabelstring_; }
204         ///
205         docstring const & preamble() const { return preamble_; }
206         ///
207         std::string const & latexparam() const { return latexparam_; }
208         ///
209         std::string const & innertag() const { return innertag_; }
210         ///
211         std::string const & labeltag() const { return labeltag_; }
212         ///
213         std::string const & itemtag() const { return itemtag_; }
214         ///
215         lyx::docstring const & labelstring_appendix() const {
216                 return labelstring_appendix_;
217         }
218         /** Default font for this layout/environment.
219             The main font for this kind of environment. If an attribute has
220             Font::INHERITED_*, it means that the value is specified by
221             the defaultfont for the entire layout. If we are nested, the
222             font is inherited from the font in the environment one level
223             up until the font is resolved. The values Font::IGNORE_*
224             and Font::TOGGLE are illegal here.
225         */
226         Font font;
227
228         /** Default font for labels.
229             Interpretation the same as for font above
230         */
231         Font labelfont;
232
233         /** Resolved version of the font for this layout/environment.
234             This is a resolved version the default font. The font is resolved
235             against the defaultfont of the entire layout.
236         */
237         Font resfont;
238
239         /** Resolved version of the font used for labels.
240             This is a resolved version the label font. The font is resolved
241             against the defaultfont of the entire layout.
242         */
243         Font reslabelfont;
244
245         /// Text that dictates how wide the left margin is on the screen
246         std::string leftmargin;
247         /// Text that dictates how wide the right margin is on the screen
248         std::string rightmargin;
249         /// Text that dictates how much space to leave after a potential label
250         std::string labelsep;
251         /// Text that dictates how much space to leave before a potential label
252         std::string labelindent;
253         /// Text that dictates the width of the indentation of indented pars
254         std::string parindent;
255         ///
256         double parskip;
257         ///
258         double itemsep;
259         ///
260         double topsep;
261         ///
262         double bottomsep;
263         ///
264         double labelbottomsep;
265         ///
266         double parsep;
267         ///
268         Spacing spacing;
269         ///
270         LyXAlignment align;
271         ///
272         LyXAlignment alignpossible;
273         ///
274         LYX_LABEL_TYPES labeltype;
275         ///
276         LYX_END_LABEL_TYPES endlabeltype;
277         ///
278         LYX_MARGIN_TYPE margintype;
279         ///
280         bool fill_top;
281         ///
282         bool fill_bottom;
283         ///
284         bool newline_allowed;
285         ///
286         bool nextnoindent;
287         ///
288         bool free_spacing;
289         ///
290         bool pass_thru;
291         /**
292          * Whether this layout was declared with "Environment xxx" as opposed
293          * to "Style xxx". This is part of some unfinished generic environment
294          * handling (see also InsetEnvironment) started by Andre. No layout
295          * that is shipped with LyX has this flag set.
296          * Don't confuse this with isEnvironment()!
297          */
298         bool is_environment;
299         /// show this in toc
300         int toclevel;
301         /// special value of toclevel for non-section layouts
302         static const int NOT_IN_TOC;
303         /// for new environment insets
304         std::string latexheader;
305         /// for new environment insets
306         std::string latexfooter;
307         /// for new environment insets
308         std::string latexparagraph;
309
310         /** true when the fragile commands in the paragraph need to be
311             \protect'ed. */
312         bool needprotect;
313         /// true when empty paragraphs should be kept.
314         bool keepempty;
315         ///
316         bool isParagraph() const {
317                 return latextype == LATEX_PARAGRAPH;
318         }
319         ///
320         bool isCommand() const {
321                 return latextype == LATEX_COMMAND;
322         }
323         ///
324         bool isEnvironment() const {
325                 return (latextype == LATEX_ENVIRONMENT
326                         || latextype == LATEX_BIB_ENVIRONMENT
327                         || latextype == LATEX_ITEM_ENVIRONMENT
328                         || latextype == LATEX_LIST_ENVIRONMENT);
329         }
330         /// Type of LaTeX object
331         LYX_LATEX_TYPES latextype;
332         /// Does this object belong in the title part of the document?
333         bool intitle;
334         /// Does this layout allow for an optional parameter?
335         int optionalargs;
336         /// Which counter to step
337         lyx::docstring counter;
338         /// Depth of XML command
339         int commanddepth;
340
341 private:
342         /// Name of the layout/paragraph environment
343         std::string name_;
344
345         /** Name of an layout that has replaced this layout.
346             This is used to rename a layout, while keeping backward
347             compatibility
348         */
349         std::string obsoleted_by_;
350
351         /** Name of an layout which preamble must come before this one
352             This is used when the preamble snippet uses macros defined in
353             another preamble
354          */
355         std::string depends_on_;
356
357         /// LaTeX name for environment
358         std::string latexname_;
359         /// Label string. "Abstract", "Reference", "Caption"...
360         lyx::docstring labelstring_;
361         ///
362         lyx::docstring endlabelstring_;
363         /// Label string inside appendix. "Appendix", ...
364         lyx::docstring labelstring_appendix_;
365         /// LaTeX parameter for environment
366         std::string latexparam_;
367         /// Internal tag to use (e.g., <title></title> for sect header)
368         std::string innertag_;
369         /// Internal tag to use e.g. to surround varlistentry label)
370         std::string labeltag_;
371         /// Internal tag to surround the item text in a list)
372         std::string itemtag_;
373         /// Macro definitions needed for this layout
374         docstring preamble_;
375 };
376
377
378 } // namespace lyx
379
380 #endif