]> git.lyx.org Git - lyx.git/blob - src/Layout.h
Update cursor and scrollbar after resize.
[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         /// Reads a layout definition from file
55         /// \return true on success.
56         bool read(Lexer &, TextClass const &);
57         ///
58         void readAlign(Lexer &);
59         ///
60         void readAlignPossible(Lexer &);
61         ///
62         void readLabelType(Lexer &);
63         ///
64         void readEndLabelType(Lexer &);
65         ///
66         void readMargin(Lexer &);
67         ///
68         void readLatexType(Lexer &);
69         ///
70         void readSpacing(Lexer &);
71         ///
72         docstring const & name() const;
73         ///
74         void setName(docstring const & n);
75         ///
76         docstring const & obsoleted_by() const;
77         ///
78         docstring const & depends_on() const;
79         ///
80         std::string const & latexname() const { return latexname_; }
81         ///
82         docstring const & labelstring() const { return labelstring_; }
83         ///
84         docstring const & endlabelstring() const { return endlabelstring_; }
85         ///
86         docstring const & preamble() const { return preamble_; }
87         ///
88         std::set<std::string> const & requires() const { return requires_; }
89         ///
90         std::string const & latexparam() const { return latexparam_; }
91         ///
92         std::string const & innertag() const { return innertag_; }
93         ///
94         std::string const & labeltag() const { return labeltag_; }
95         ///
96         std::string const & itemtag() const { return itemtag_; }
97         ///
98         docstring const & labelstring_appendix() const {
99                 return labelstring_appendix_;
100         }
101         /** Default font for this layout/environment.
102             The main font for this kind of environment. If an attribute has
103             INHERITED_*, it means that the value is specified by
104             the defaultfont for the entire layout. If we are nested, the
105             font is inherited from the font in the environment one level
106             up until the font is resolved. The values :IGNORE_*
107             and FONT_TOGGLE are illegal here.
108         */
109         FontInfo font;
110
111         /** Default font for labels.
112             Interpretation the same as for font above
113         */
114         FontInfo labelfont;
115
116         /** Resolved version of the font for this layout/environment.
117             This is a resolved version the default font. The font is resolved
118             against the defaultfont of the entire layout.
119         */
120         FontInfo resfont;
121
122         /** Resolved version of the font used for labels.
123             This is a resolved version the label font. The font is resolved
124             against the defaultfont of the entire layout.
125         */
126         FontInfo reslabelfont;
127
128         /// Text that dictates how wide the left margin is on the screen
129         docstring leftmargin;
130         /// Text that dictates how wide the right margin is on the screen
131         docstring rightmargin;
132         /// Text that dictates how much space to leave after a potential label
133         docstring labelsep;
134         /// Text that dictates how much space to leave before a potential label
135         docstring labelindent;
136         /// Text that dictates the width of the indentation of indented pars
137         docstring parindent;
138         ///
139         double parskip;
140         ///
141         double itemsep;
142         ///
143         double topsep;
144         ///
145         double bottomsep;
146         ///
147         double labelbottomsep;
148         ///
149         double parsep;
150         ///
151         Spacing spacing;
152         ///
153         LyXAlignment align;
154         ///
155         LyXAlignment alignpossible;
156         ///
157         LabelType labeltype;
158         ///
159         EndLabelType endlabeltype;
160         ///
161         MarginType margintype;
162         ///
163         bool fill_top;
164         ///
165         bool fill_bottom;
166         ///
167         bool newline_allowed;
168         ///
169         bool nextnoindent;
170         ///
171         bool free_spacing;
172         ///
173         bool pass_thru;
174         /**
175          * Whether this layout was declared with "Environment xxx" as opposed
176          * to "Style xxx". This is part of some unfinished generic environment
177          * handling (see also InsetEnvironment) started by Andre. No layout
178          * that is shipped with LyX has this flag set.
179          * Don't confuse this with isEnvironment()!
180          */
181         bool is_environment;
182         /// show this in toc
183         int toclevel;
184         /// special value of toclevel for non-section layouts
185         static const int NOT_IN_TOC;
186         /// for new environment insets
187         std::string latexheader;
188         /// for new environment insets
189         std::string latexfooter;
190         /// for new environment insets
191         std::string latexparagraph;
192
193         /** true when the fragile commands in the paragraph need to be
194             \protect'ed. */
195         bool needprotect;
196         /// true when empty paragraphs should be kept.
197         bool keepempty;
198         ///
199         bool isParagraph() const { return latextype == LATEX_PARAGRAPH; }
200         ///
201         bool isCommand() const { return latextype == LATEX_COMMAND; }
202         ///
203         bool isEnvironment() const {
204                 return latextype == LATEX_ENVIRONMENT
205                         || latextype == LATEX_BIB_ENVIRONMENT
206                         || latextype == LATEX_ITEM_ENVIRONMENT
207                         || latextype == LATEX_LIST_ENVIRONMENT;
208         }
209         /// Type of LaTeX object
210         LatexType latextype;
211         /// Does this object belong in the title part of the document?
212         bool intitle;
213         /// Does this layout allow for an optional parameter?
214         int optionalargs;
215         /// Which counter to step
216         docstring counter;
217         /// Depth of XML command
218         int commanddepth;
219
220         /// Return a pointer on a new layout suitable to describe a caption.
221         /// FIXME: remove this eventually. This is only for tex2lyx
222         /// until it has proper support for the caption inset (JMarc)
223         static Layout * forCaption();
224
225 private:
226         /// Name of the layout/paragraph environment
227         docstring name_;
228
229         /** Name of an layout that has replaced this layout.
230             This is used to rename a layout, while keeping backward
231             compatibility
232         */
233         docstring obsoleted_by_;
234
235         /** Name of an layout which preamble must come before this one
236             This is used when the preamble snippet uses macros defined in
237             another preamble
238          */
239         docstring depends_on_;
240
241         /// LaTeX name for environment
242         std::string latexname_;
243         /// Label string. "Abstract", "Reference", "Caption"...
244         docstring labelstring_;
245         ///
246         docstring endlabelstring_;
247         /// Label string inside appendix. "Appendix", ...
248         docstring labelstring_appendix_;
249         /// LaTeX parameter for environment
250         std::string latexparam_;
251         /// Internal tag to use (e.g., <title></title> for sect header)
252         std::string innertag_;
253         /// Internal tag to use e.g. to surround varlistentry label)
254         std::string labeltag_;
255         /// Internal tag to surround the item text in a list)
256         std::string itemtag_;
257         /// Macro definitions needed for this layout
258         docstring preamble_;
259         /// Packages needed for this layout
260         std::set<std::string> requires_;
261 };
262
263 } // namespace lyx
264
265 #endif