2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 The LyX Team.
10 * ====================================================== */
23 #include "definitions.h"
28 /// Reads the style files
29 extern void LyXSetStyle();
31 /// The different output types
43 /// The different margin types
44 enum LYX_MARGIN_TYPE {
54 MARGIN_RIGHT_ADDRESS_BOX
70 LYX_ALIGN_LAYOUT = 16,
72 LYX_ALIGN_SPECIAL = 32
74 inline void operator|=(LyXAlignment & la1, LyXAlignment la2) {
75 la1 = static_cast<LyXAlignment>(la1 | la2);
78 /// The different LaTeX-Types
79 enum LYX_LATEX_TYPES {
87 LATEX_ITEM_ENVIRONMENT,
89 LATEX_LIST_ENVIRONMENT
92 /// The different label types
93 enum LYX_LABEL_TYPES {
101 LABEL_TOP_ENVIRONMENT,
103 LABEL_CENTERED_TOP_ENVIRONMENT,
105 // the flushright labels following now must start with LABEL_STATIC
111 LABEL_COUNTER_CHAPTER,
113 LABEL_COUNTER_SECTION,
115 LABEL_COUNTER_SUBSECTION,
117 LABEL_COUNTER_SUBSUBSECTION,
119 LABEL_COUNTER_PARAGRAPH,
121 LABEL_COUNTER_SUBPARAGRAPH,
125 LABEL_COUNTER_ENUMII,
127 LABEL_COUNTER_ENUMIII,
129 LABEL_COUNTER_ENUMIV,
131 LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
135 /* Fix labels are printed flushright, manual labels flushleft.
136 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
137 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
138 * This seems a funny restriction, but I think other combinations are
139 * not needed, so I will not change it yet.
140 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
144 /* There is a parindent and a parskip. Which one is used depends on the
145 * paragraph_separation-flag of the text-object.
146 * BUT: parindent is only thrown away, if a parskip is defined! So if you
147 * want a space between the paragraphs and a parindent at the same time,
148 * you should set parskip to zero and use topsep, parsep and bottomsep.
150 * The standard layout is an exception: its parindent is only set, if the
151 * previous paragraph is standard too. Well, this is LateX and it is good!
155 /// Attributes of a layout/paragraph environment
165 bool Read (LyXLex &, LyXTextClass const &);
167 string const & name() const { return name_; }
168 void name(string const & n) { name_ = n; }
169 string const & obsoleted_by() const { return obsoleted_by_; }
170 string const & latexname() const { return latexname_; }
171 string const & labelstring() const { return labelstring_; }
172 string const & preamble() const { return preamble_; }
173 string const & latexparam() const { return latexparam_; }
174 string const & labelstring_appendix() const { return labelstring_appendix_; }
175 /** Default font for this layout/environment.
176 The main font for this kind of environment. If an attribute has
177 LyXFont::INHERITED_*, it means that the value is specified by
178 the defaultfont for the entire layout. If we are nested, the
179 font is inherited from the font in the environment one level
180 up until the font is resolved. The values LyXFont::IGNORE_*
181 and LyXFont::TOGGLE are illegal here.
185 /** Default font for labels.
186 Interpretation the same as for font above
190 /** Resolved version of the font for this layout/environment.
191 This is a resolved version the default font. The font is resolved
192 against the defaultfont of the entire layout.
196 /** Resolved version of the font used for labels.
197 This is a resolved version the label font. The font is resolved
198 against the defaultfont of the entire layout.
200 LyXFont reslabelfont;
202 /// Text that dictates how wide the left margin is on the screen
205 /// Text that dictates how wide the right margin is on the screen
208 /// Text that dictates how much space to leave after a potential label
211 /// Text that dictates how much space to leave before a potential label
214 /** Text that dictates the width of the indentation of
232 float labelbottomsep;
241 LyXAlignment align; // add approp. signedness
244 LyXAlignment alignpossible; // add approp. signedness
247 char labeltype; // add approp. signedness
250 char margintype; // add approp. signedness
259 bool newline_allowed;
266 /// true when the fragile commands in the paragraph need to be
269 /// true when empty paragraphs should be kept.
272 bool isParagraph() const {
273 return latextype == LATEX_PARAGRAPH;
276 bool isCommand() const {
277 return latextype == LATEX_COMMAND;
280 bool isEnvironment() const {
281 return (latextype == LATEX_ENVIRONMENT
282 || latextype == LATEX_ITEM_ENVIRONMENT
283 || latextype == LATEX_LIST_ENVIRONMENT);
285 /// Type of LaTeX object
286 LYX_LATEX_TYPES latextype;
287 /// Does this object belong in the title part of the document?
290 /// Name of the layout/paragraph environment
293 /** Name of an layout that has replaced this layout.
294 This is used to rename a layout, while keeping backward
297 string obsoleted_by_;
299 /// LaTeX name for environment
302 /// Label string. "Abstract", "Reference", "Caption"...
305 /// Label string inside appendix. "Appendix", ...
306 string labelstring_appendix_;
308 /// LaTeX parameter for environment
311 /// Macro definitions needed for this layout
320 typedef vector<LyXLayout> LayoutList;
323 LyXTextClass (string const & = string(),
324 string const & = string(),
325 string const & = string());
328 LayoutList::const_iterator begin() const { return layoutlist.begin(); }
330 LayoutList::const_iterator end() const { return layoutlist.end(); }
333 bool Read(string const & filename, bool merge = false);
336 bool hasLayout(string const & name) const;
339 LyXLayout const & GetLayout(string const & vname) const;
342 LyXLayout & GetLayout(string const & vname);
344 /// Sees to that the textclass structure has been loaded
348 string const & name() const { return name_; }
350 string const & latexname() const { return latexname_; }
352 string const & description() const { return description_; }
354 string const & opt_fontsize() const { return opt_fontsize_; }
356 string const & opt_pagestyle() const { return opt_pagestyle_; }
358 string const & options() const { return options_; }
360 string const & pagestyle() const { return pagestyle_; }
362 string const & preamble() const { return preamble_; }
364 /// Packages that are already loaded by the class
371 bool provides(Provides p) const { return provides_ & p; }
374 unsigned int columns() const { return columns_; }
381 PageSides sides() const { return sides_; }
383 int secnumdepth() const { return secnumdepth_; }
385 int tocdepth() const { return tocdepth_; }
388 OutputType outputType() const { return outputType_; }
391 LyXFont const & defaultfont() const { return defaultfont_; }
393 /// Text that dictates how wide the left margin is on the screen
394 string const & leftmargin() const { return leftmargin_; }
396 /// Text that dictates how wide the right margin is on the screen
397 string const & rightmargin() const { return rightmargin_; }
399 int maxcounter() const { return maxcounter_; }
401 LayoutList::size_type numLayouts() const { return layoutlist.size(); }
403 LyXLayout const & operator[](LayoutList::size_type i) const {
404 return layoutlist[i];
408 bool delete_layout(string const &);
410 bool do_readStyle(LyXLex &, LyXLayout &);
417 /// Specific class options
418 string opt_fontsize_;
420 string opt_pagestyle_;
430 unsigned int columns_;
438 OutputType outputType_;
439 /** Base font. The paragraph and layout fonts are resolved against
440 this font. This has to be fully instantiated. Attributes
441 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
444 LyXFont defaultfont_;
445 /// Text that dictates how wide the left margin is on the screen
448 /// Text that dictates how wide the right margin is on the screen
451 int maxcounter_; // add approp. signedness
454 LayoutList layoutlist;
456 /// Has this layout file been loaded yet?
461 inline void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
463 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
468 class LyXTextClassList {
471 typedef vector<LyXTextClass> ClassList;
472 /// Gets layout structure from layout number and textclass number
473 LyXLayout const & Style(ClassList::size_type textclass,
474 LyXTextClass::LayoutList::size_type layout) const;
476 /// Gets layout number from textclass number and layout name
477 pair<bool, LyXTextClass::LayoutList::size_type>
478 NumberOfLayout(ClassList::size_type textclass,
479 string const & name) const;
481 /// Gets a layout name from layout number and textclass number
483 NameOfLayout(ClassList::size_type textclass,
484 LyXTextClass::LayoutList::size_type layout) const;
486 /** Gets textclass number from name.
487 Returns -1 if textclass name does not exist
489 pair<bool, ClassList::size_type>
490 NumberOfClass(string const & textclass) const;
493 string const & NameOfClass(ClassList::size_type number) const;
496 string const & LatexnameOfClass(ClassList::size_type number) const;
499 string const & DescOfClass(ClassList::size_type number) const;
502 LyXTextClass const & TextClass(ClassList::size_type textclass) const;
504 /** Read textclass list.
505 Returns false if this fails
510 Returns false if this fails
512 bool Load(ClassList::size_type number) const;
515 mutable ClassList classlist;
517 void Add (LyXTextClass const &);
520 /// Should not be declared here!! (Lgb) Why not? (Asger)
521 extern LyXTextClassList textclasslist;