]> git.lyx.org Git - lyx.git/blob - src/lyxlayout.h
324bd3c028efbaac59eb7cb6023f803ef3294bea
[lyx.git] / src / lyxlayout.h
1 // -*- C++ -*-
2 /**
3  * \file lyxlayout.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 "lyxfont.h"
18 #include "layout.h"
19 #include "Spacing.h"
20 #include "support/docstring.h"
21
22 #include <string>
23
24 class LyXLex;
25 class LyXTextClass;
26
27 ///
28 class LyXLayout {
29 public:
30         ///
31         LyXLayout();
32         ///
33         bool read(LyXLex &, LyXTextClass const &);
34         ///
35         void readAlign(LyXLex &);
36         ///
37         void readAlignPossible(LyXLex &);
38         ///
39         void readLabelType(LyXLex &);
40         ///
41         void readEndLabelType(LyXLex &);
42         ///
43         void readMargin(LyXLex &);
44         ///
45         void readLatexType(LyXLex &);
46         ///
47         void readSpacing(LyXLex &);
48         ///
49         std::string const & name() const;
50         ///
51         void setName(std::string const & n);
52         ///
53         std::string const & obsoleted_by() const;
54         ///
55         std::string const & depends_on() const;
56         ///
57         std::string const & latexname() const { return latexname_; }
58         ///
59         lyx::docstring const & labelstring() const { return labelstring_; }
60         ///
61         lyx::docstring const & endlabelstring() const { return endlabelstring_; }
62         ///
63         std::string const & preamble() const { return preamble_; }
64         ///
65         std::string const & latexparam() const { return latexparam_; }
66         ///
67         std::string const & innertag() const { return innertag_; }
68         ///
69         std::string const & labeltag() const { return labeltag_; }
70         ///
71         std::string const & itemtag() const { return itemtag_; }
72         ///
73         lyx::docstring const & labelstring_appendix() const {
74                 return labelstring_appendix_;
75         }
76         /** Default font for this layout/environment.
77             The main font for this kind of environment. If an attribute has
78             LyXFont::INHERITED_*, it means that the value is specified by
79             the defaultfont for the entire layout. If we are nested, the
80             font is inherited from the font in the environment one level
81             up until the font is resolved. The values LyXFont::IGNORE_*
82             and LyXFont::TOGGLE are illegal here.
83         */
84         LyXFont font;
85
86         /** Default font for labels.
87             Interpretation the same as for font above
88         */
89         LyXFont labelfont;
90
91         /** Resolved version of the font for this layout/environment.
92             This is a resolved version the default font. The font is resolved
93             against the defaultfont of the entire layout.
94         */
95         LyXFont resfont;
96
97         /** Resolved version of the font used for labels.
98             This is a resolved version the label font. The font is resolved
99             against the defaultfont of the entire layout.
100         */
101         LyXFont reslabelfont;
102
103         /// Text that dictates how wide the left margin is on the screen
104         std::string leftmargin;
105         /// Text that dictates how wide the right margin is on the screen
106         std::string rightmargin;
107         /// Text that dictates how much space to leave after a potential label
108         std::string labelsep;
109         /// Text that dictates how much space to leave before a potential label
110         std::string labelindent;
111         /// Text that dictates the width of the indentation of indented pars
112         std::string parindent;
113         ///
114         double parskip;
115         ///
116         double itemsep;
117         ///
118         double topsep;
119         ///
120         double bottomsep;
121         ///
122         double labelbottomsep;
123         ///
124         double parsep;
125         ///
126         Spacing spacing;
127         ///
128         LyXAlignment align;
129         ///
130         LyXAlignment alignpossible;
131         ///
132         LYX_LABEL_TYPES labeltype;
133         ///
134         LYX_END_LABEL_TYPES endlabeltype;
135         ///
136         LYX_MARGIN_TYPE margintype;
137         ///
138         bool fill_top;
139         ///
140         bool fill_bottom;
141         ///
142         bool newline_allowed;
143         ///
144         bool nextnoindent;
145         ///
146         bool free_spacing;
147         ///
148         bool pass_thru;
149         ///
150         bool is_environment;
151         /// show this in toc
152         int toclevel;
153         /// special value of toclevel for non-section layouts
154         static const int NOT_IN_TOC;
155         /// for new environment insets
156         std::string latexheader;
157         /// for new environment insets
158         std::string latexfooter;
159         /// for new environment insets
160         std::string latexparagraph;
161
162         /** true when the fragile commands in the paragraph need to be
163             \protect'ed. */
164         bool needprotect;
165         /// true when empty paragraphs should be kept.
166         bool keepempty;
167         ///
168         bool isParagraph() const {
169                 return latextype == LATEX_PARAGRAPH;
170         }
171         ///
172         bool isCommand() const {
173                 return latextype == LATEX_COMMAND;
174         }
175         ///
176         bool isEnvironment() const {
177                 return (latextype == LATEX_ENVIRONMENT
178                         || latextype == LATEX_BIB_ENVIRONMENT
179                         || latextype == LATEX_ITEM_ENVIRONMENT
180                         || latextype == LATEX_LIST_ENVIRONMENT);
181         }
182         /// Type of LaTeX object
183         LYX_LATEX_TYPES latextype;
184         /// Does this object belong in the title part of the document?
185         bool intitle;
186         /// Does this layout allow for an optional parameter?
187         int optionalargs;
188         /// Which counter to step
189         lyx::docstring counter;
190         /// Depth of XML command
191         int commanddepth;
192
193 private:
194         /// Name of the layout/paragraph environment
195         std::string name_;
196
197         /** Name of an layout that has replaced this layout.
198             This is used to rename a layout, while keeping backward
199             compatibility
200         */
201         std::string obsoleted_by_;
202
203         /** Name of an layout which preamble must come before this one
204             This is used when the preamble snippet uses macros defined in
205             another preamble
206          */
207         std::string depends_on_;
208
209         /// LaTeX name for environment
210         std::string latexname_;
211         /// Label string. "Abstract", "Reference", "Caption"...
212         lyx::docstring labelstring_;
213         ///
214         lyx::docstring endlabelstring_;
215         /// Label string inside appendix. "Appendix", ...
216         lyx::docstring labelstring_appendix_;
217         /// LaTeX parameter for environment
218         std::string latexparam_;
219         /// Internal tag to use (e.g., <title></title> for sect header)
220         std::string innertag_;
221         /// Internal tag to use e.g. to surround varlistentry label)
222         std::string labeltag_;
223         /// Internal tag to surround the item text in a list)
224         std::string itemtag_;
225         /// Macro definitions needed for this layout
226         std::string preamble_;
227 };
228
229 #endif