]> git.lyx.org Git - lyx.git/blob - src/Layout.h
* GuiView.cpp:
[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         /// for new environment insets
210         std::string latexheader;
211         /// for new environment insets
212         std::string latexfooter;
213         /// for new environment insets
214         std::string latexparagraph;
215
216         /** true when the fragile commands in the paragraph need to be
217             \protect'ed. */
218         bool needprotect;
219         /// true when empty paragraphs should be kept.
220         bool keepempty;
221         /// Type of LaTeX object
222         LatexType latextype;
223         /// Does this object belong in the title part of the document?
224         bool intitle;
225         /// Does this layout allow for an optional parameter?
226         int optionalargs;
227         /// Which counter to step
228         docstring counter;
229         /// Depth of XML command
230         int commanddepth;
231
232         /// Return a pointer on a new layout suitable to describe a caption.
233         /// FIXME: remove this eventually. This is only for tex2lyx
234         /// until it has proper support for the caption inset (JMarc)
235         static Layout * forCaption();
236
237         /// Name of the layout/paragraph environment
238         docstring name_;
239         /// LaTeX name for environment
240         std::string latexname_;
241
242 private:
243         /** Name of an layout that has replaced this layout.
244             This is used to rename a layout, while keeping backward
245             compatibility
246         */
247         docstring obsoleted_by_;
248
249         /** Name of an layout which preamble must come before this one
250             This is used when the preamble snippet uses macros defined in
251             another preamble
252          */
253         docstring depends_on_;
254
255         /// Label string. "Abstract", "Reference", "Caption"...
256         docstring labelstring_;
257         ///
258         docstring endlabelstring_;
259         /// Label string inside appendix. "Appendix", ...
260         docstring labelstring_appendix_;
261         /// LaTeX parameter for environment
262         std::string latexparam_;
263         /// Internal tag to use (e.g., <title></title> for sect header)
264         std::string innertag_;
265         /// Internal tag to use e.g. to surround varlistentry label)
266         std::string labeltag_;
267         /// Internal tag to surround the item text in a list)
268         std::string itemtag_;
269         /// This is the `category' for this layout. The following are
270         /// recommended basic categories: FrontMatter, BackMatter, MainText,
271         /// Section, Starred, List, Theorem.
272         docstring category_;
273         /// Macro definitions needed for this layout
274         docstring preamble_;
275         /// Packages needed for this layout
276         std::set<std::string> requires_;
277 };
278
279 } // namespace lyx
280
281 #endif