]> git.lyx.org Git - lyx.git/blob - src/lyxlayout.h
Alfredo's second patch
[lyx.git] / src / lyxlayout.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef LYX_LAYOUT_H
13 #define LYX_LAYOUT_H
14
15 #include "lyxfont.h"
16 #include "layout.h"
17 #include "Spacing.h"
18 #include "LString.h"
19
20 class LyXLex;
21 class LyXTextClass;
22
23 ///
24 class LyXLayout {
25 public:
26         ///
27         LyXLayout();
28         ///
29         bool Read(LyXLex &, LyXTextClass const &);
30         ///
31         void readAlign(LyXLex &);
32         ///
33         void readAlignPossible(LyXLex &);
34         ///
35         void readLabelType(LyXLex &);
36         ///
37         void readEndLabelType(LyXLex &);
38         ///
39         void readMargin(LyXLex &);
40         ///
41         void readLatexType(LyXLex &);
42         ///
43         void readSpacing(LyXLex &);
44         ///
45         string const & name() const;
46         ///
47         void setName(string const & n);
48         ///
49         string const & obsoleted_by() const;
50         ///
51         string const & depends_on() const;
52         ///
53         string const & latexname() const { return latexname_; }
54         ///
55         string const & labelstring() const { return labelstring_; }
56         ///
57         string const & endlabelstring() const { return endlabelstring_; }
58         ///
59         string const & preamble() const { return preamble_; }
60         ///
61         string const & latexparam() const { return latexparam_; }
62         ///
63         string const & labelstring_appendix() const {
64                 return labelstring_appendix_;
65         }
66         /** Default font for this layout/environment.
67             The main font for this kind of environment. If an attribute has
68             LyXFont::INHERITED_*, it means that the value is specified by
69             the defaultfont for the entire layout. If we are nested, the
70             font is inherited from the font in the environment one level
71             up until the font is resolved. The values LyXFont::IGNORE_*
72             and LyXFont::TOGGLE are illegal here.
73         */
74         LyXFont font;
75
76         /** Default font for labels.
77             Interpretation the same as for font above
78         */
79         LyXFont labelfont;
80
81         /** Resolved version of the font for this layout/environment.
82             This is a resolved version the default font. The font is resolved
83             against the defaultfont of the entire layout.
84         */
85         LyXFont resfont;
86
87         /** Resolved version of the font used for labels.
88             This is a resolved version the label font. The font is resolved
89             against the defaultfont of the entire layout.
90         */
91         LyXFont reslabelfont;
92
93         /// Text that dictates how wide the left margin is on the screen
94         string leftmargin;
95         /// Text that dictates how wide the right margin is on the screen
96         string rightmargin;
97         /// Text that dictates how much space to leave after a potential label
98         string labelsep;
99         /// Text that dictates how much space to leave before a potential label
100         string labelindent;
101         /// Text that dictates the width of the indentation of indented pars
102         string parindent;
103         ///
104         float parskip;
105         ///
106         float itemsep;
107         ///
108         float topsep;
109         ///
110         float bottomsep;
111         ///
112         float labelbottomsep;
113         ///
114         float parsep;
115         ///
116         Spacing spacing;
117         ///
118         LyXAlignment align;
119         ///
120         LyXAlignment alignpossible;
121         ///
122         char labeltype; // add approp. type
123         ///
124         LYX_END_LABEL_TYPES endlabeltype;
125         ///
126         LYX_MARGIN_TYPE margintype;
127         ///
128         bool fill_top;
129         ///
130         bool fill_bottom;
131         ///
132         bool newline_allowed;
133         ///
134         bool nextnoindent;
135         ///
136         bool free_spacing;
137         ///
138         bool pass_thru;
139         /// for new environment insets
140         string latexheader;
141         /// for new environment insets
142         string latexfooter;
143
144         /** true when the fragile commands in the paragraph need to be
145             \protect'ed. */
146         bool needprotect;
147         /// true when empty paragraphs should be kept.
148         bool keepempty;
149         ///
150         bool isParagraph() const {
151                 return latextype == LATEX_PARAGRAPH;
152         }
153         ///
154         bool isCommand() const {
155                 return latextype == LATEX_COMMAND;
156         }
157         ///
158         bool isEnvironment() const {
159                 return (latextype == LATEX_ENVIRONMENT
160                         || latextype == LATEX_BIB_ENVIRONMENT
161                         || latextype == LATEX_ITEM_ENVIRONMENT
162                         || latextype == LATEX_LIST_ENVIRONMENT);
163         }
164         /// Type of LaTeX object
165         LYX_LATEX_TYPES latextype;
166         /// Does this object belong in the title part of the document?
167         bool intitle;
168         /// Does this layout allow for an optional parameter?
169         int optionalargs;
170
171 private:
172         /// Name of the layout/paragraph environment
173         string name_;
174
175         /** Name of an layout that has replaced this layout.
176             This is used to rename a layout, while keeping backward
177             compatibility
178         */
179         string obsoleted_by_;
180
181         /** Name of an layout which preamble must come before this one
182             This is used when the preamble snippet uses macros defined in
183             another preamble
184          */
185         string depends_on_;
186
187         /// LaTeX name for environment
188         string latexname_;
189         /// Label string. "Abstract", "Reference", "Caption"...
190         string labelstring_;
191         ///
192         string endlabelstring_;
193         /// Label string inside appendix. "Appendix", ...
194         string labelstring_appendix_;
195         /// LaTeX parameter for environment
196         string latexparam_;
197         /// Macro definitions needed for this layout
198         string preamble_;
199 };
200
201 #endif