]> git.lyx.org Git - lyx.git/blob - src/Layout.h
0e4943dab1b5efbddc5789f11eb6457191f69fcc
[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 namespace lyx {
23
24 class Lexer;
25 class TextClass;
26
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
33  */
34
35
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.
41  *
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!
44  */
45
46 ///
47 class Layout {
48 public:
49         ///
50         Layout();
51         /// Reads a layout definition from file
52         bool read(Lexer &, TextClass const &);
53         ///
54         void readAlign(Lexer &);
55         ///
56         void readAlignPossible(Lexer &);
57         ///
58         void readLabelType(Lexer &);
59         ///
60         void readEndLabelType(Lexer &);
61         ///
62         void readMargin(Lexer &);
63         ///
64         void readLatexType(Lexer &);
65         ///
66         void readSpacing(Lexer &);
67         ///
68         docstring const & name() const;
69         ///
70         void setName(docstring const & n);
71         ///
72         docstring const & obsoleted_by() const;
73         ///
74         docstring const & depends_on() const;
75         ///
76         std::string const & latexname() const { return latexname_; }
77         ///
78         docstring const & labelstring() const { return labelstring_; }
79         ///
80         docstring const & endlabelstring() const { return endlabelstring_; }
81         ///
82         docstring const & preamble() const { return preamble_; }
83         ///
84         std::string const & latexparam() const { return latexparam_; }
85         ///
86         std::string const & innertag() const { return innertag_; }
87         ///
88         std::string const & labeltag() const { return labeltag_; }
89         ///
90         std::string const & itemtag() const { return itemtag_; }
91         ///
92         docstring const & labelstring_appendix() const {
93                 return labelstring_appendix_;
94         }
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.
102         */
103         FontInfo font;
104
105         /** Default font for labels.
106             Interpretation the same as for font above
107         */
108         FontInfo labelfont;
109
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.
113         */
114         FontInfo resfont;
115
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.
119         */
120         FontInfo reslabelfont;
121
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
127         docstring labelsep;
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
131         docstring parindent;
132         ///
133         double parskip;
134         ///
135         double itemsep;
136         ///
137         double topsep;
138         ///
139         double bottomsep;
140         ///
141         double labelbottomsep;
142         ///
143         double parsep;
144         ///
145         Spacing spacing;
146         ///
147         LyXAlignment align;
148         ///
149         LyXAlignment alignpossible;
150         ///
151         LabelType labeltype;
152         ///
153         EndLabelType endlabeltype;
154         ///
155         MarginType margintype;
156         ///
157         bool fill_top;
158         ///
159         bool fill_bottom;
160         ///
161         bool newline_allowed;
162         ///
163         bool nextnoindent;
164         ///
165         bool free_spacing;
166         ///
167         bool pass_thru;
168         /**
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()!
174          */
175         bool is_environment;
176         /// show this in toc
177         int toclevel;
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;
186
187         /** true when the fragile commands in the paragraph need to be
188             \protect'ed. */
189         bool needprotect;
190         /// true when empty paragraphs should be kept.
191         bool keepempty;
192         ///
193         bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
194         ///
195         bool isCommand() const { return latextype == LATEX_COMMAND; }
196         ///
197         bool isEnvironment() const {
198                 return latextype == LATEX_ENVIRONMENT
199                         || latextype == LATEX_BIB_ENVIRONMENT
200                         || latextype == LATEX_ITEM_ENVIRONMENT
201                         || latextype == LATEX_LIST_ENVIRONMENT;
202         }
203         /// Type of LaTeX object
204         LatexType latextype;
205         /// Does this object belong in the title part of the document?
206         bool intitle;
207         /// Does this layout allow for an optional parameter?
208         int optionalargs;
209         /// Which counter to step
210         docstring counter;
211         /// Depth of XML command
212         int commanddepth;
213
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();
218
219 private:
220         /// Name of the layout/paragraph environment
221         docstring name_;
222
223         /** Name of an layout that has replaced this layout.
224             This is used to rename a layout, while keeping backward
225             compatibility
226         */
227         docstring obsoleted_by_;
228
229         /** Name of an layout which preamble must come before this one
230             This is used when the preamble snippet uses macros defined in
231             another preamble
232          */
233         docstring depends_on_;
234
235         /// LaTeX name for environment
236         std::string latexname_;
237         /// Label string. "Abstract", "Reference", "Caption"...
238         docstring labelstring_;
239         ///
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
252         docstring preamble_;
253 };
254
255 } // namespace lyx
256
257 #endif