]> git.lyx.org Git - lyx.git/blob - src/lyxlayout.h
layout as string
[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 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "lyxfont.h"
20 #include "layout.h"
21 #include "Spacing.h"
22 #include "LString.h"
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         string const & name() const;
50         ///
51         void setName(string const & n);
52         ///
53         string const & obsoleted_by() const;
54         ///
55         string const & latexname() const { return latexname_; }
56         ///
57         string const & labelstring() const { return labelstring_; }
58         ///
59         string const & endlabelstring() const { return endlabelstring_; }
60         ///
61         string const & preamble() const { return preamble_; }
62         ///
63         string const & latexparam() const { return latexparam_; }
64         ///
65         string const & labelstring_appendix() const {
66                 return labelstring_appendix_;
67         }
68         /** Default font for this layout/environment.
69             The main font for this kind of environment. If an attribute has
70             LyXFont::INHERITED_*, it means that the value is specified by
71             the defaultfont for the entire layout. If we are nested, the
72             font is inherited from the font in the environment one level
73             up until the font is resolved. The values LyXFont::IGNORE_*
74             and LyXFont::TOGGLE are illegal here.
75         */
76         LyXFont font;
77
78         /** Default font for labels.
79             Interpretation the same as for font above
80         */
81         LyXFont labelfont;
82
83         /** Resolved version of the font for this layout/environment.
84             This is a resolved version the default font. The font is resolved
85             against the defaultfont of the entire layout.
86         */
87         LyXFont resfont;
88
89         /** Resolved version of the font used for labels.
90             This is a resolved version the label font. The font is resolved
91             against the defaultfont of the entire layout.
92         */
93         LyXFont reslabelfont;
94
95         /// Text that dictates how wide the left margin is on the screen
96         string leftmargin;
97
98         /// Text that dictates how wide the right margin is on the screen
99         string rightmargin;
100
101         /// Text that dictates how much space to leave after a potential label
102         string labelsep;
103
104         /// Text that dictates how much space to leave before a potential label
105         string labelindent;
106
107         /** Text that dictates the width of the indentation of
108             indented paragraphs.
109         */
110         string parindent;
111
112         ///
113         float parskip;
114
115         ///
116         float itemsep;
117
118         ///
119         float topsep;
120
121         ///
122         float bottomsep;
123
124         ///
125         float labelbottomsep;
126
127         ///
128         float parsep;
129
130         ///
131         Spacing spacing;
132
133         ///
134         LyXAlignment align;
135
136         ///
137         LyXAlignment alignpossible;
138
139         ///
140         char labeltype; // add approp. type
141
142         ///
143         LYX_END_LABEL_TYPES endlabeltype;
144
145         ///
146         LYX_MARGIN_TYPE margintype;
147
148         ///
149         bool fill_top;
150
151         ///
152         bool fill_bottom;
153
154         ///
155         bool newline_allowed;
156
157         ///
158         bool nextnoindent;
159
160         ///
161         bool free_spacing;
162
163         ///
164         bool pass_thru;
165
166         /** true when the fragile commands in the paragraph need to be
167             \protect'ed. */
168         bool needprotect;
169         /// true when empty paragraphs should be kept.
170         bool keepempty;
171         ///
172         bool isParagraph() const {
173                 return latextype == LATEX_PARAGRAPH;
174         }
175         ///
176         bool isCommand() const { 
177                 return latextype == LATEX_COMMAND;
178         }
179         ///
180         bool isEnvironment() const {
181                 return (latextype == LATEX_ENVIRONMENT
182                         || latextype == LATEX_ITEM_ENVIRONMENT
183                         || latextype == LATEX_LIST_ENVIRONMENT);
184         }
185         /// Type of LaTeX object
186         LYX_LATEX_TYPES latextype;
187         /// Does this object belong in the title part of the document?
188         bool intitle;
189 private:
190         /// Name of the layout/paragraph environment
191         string name_;
192
193         /** Name of an layout that has replaced this layout.
194             This is used to rename a layout, while keeping backward
195             compatibility 
196         */
197         string obsoleted_by_;
198
199         /// LaTeX name for environment
200         string latexname_;
201
202         /// Label string. "Abstract", "Reference", "Caption"...
203         string labelstring_;
204
205         ///
206         string endlabelstring_;
207
208         /// Label string inside appendix. "Appendix", ...
209         string labelstring_appendix_;
210
211         /// LaTeX parameter for environment
212         string latexparam_;
213
214         /// Macro definitions needed for this layout
215         string preamble_;
216 };
217
218 #endif