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