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 * ====================================================== */
27 /// Reads the style files
28 extern void LyXSetStyle();
31 enum { // no good name for this
33 LYX_ENVIRONMENT_DEFAULT = 97,
35 LYX_LAYOUT_DEFAULT = 99
37 // Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has
38 // the same value? (Lgb)
40 #define LYX_DUMMY_LAYOUT 99
42 /// The different output types
54 /// The different margin types
55 enum LYX_MARGIN_TYPE {
65 MARGIN_RIGHT_ADDRESS_BOX
81 LYX_ALIGN_LAYOUT = 16,
83 LYX_ALIGN_SPECIAL = 32
87 inline void operator|=(LyXAlignment & la1, LyXAlignment la2) {
88 la1 = static_cast<LyXAlignment>(la1 | la2);
91 /// The different LaTeX-Types
92 enum LYX_LATEX_TYPES {
100 LATEX_ITEM_ENVIRONMENT,
102 LATEX_LIST_ENVIRONMENT
105 /// The different label types
106 enum LYX_LABEL_TYPES {
114 LABEL_TOP_ENVIRONMENT,
116 LABEL_CENTERED_TOP_ENVIRONMENT,
118 // the flushright labels following now must start with LABEL_STATIC
124 LABEL_COUNTER_CHAPTER,
126 LABEL_COUNTER_SECTION,
128 LABEL_COUNTER_SUBSECTION,
130 LABEL_COUNTER_SUBSUBSECTION,
132 LABEL_COUNTER_PARAGRAPH,
134 LABEL_COUNTER_SUBPARAGRAPH,
138 LABEL_COUNTER_ENUMII,
140 LABEL_COUNTER_ENUMIII,
142 LABEL_COUNTER_ENUMIV,
144 LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
148 /* Fix labels are printed flushright, manual labels flushleft.
149 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
150 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
151 * This seems a funny restriction, but I think other combinations are
152 * not needed, so I will not change it yet.
153 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
157 /* There is a parindent and a parskip. Which one is used depends on the
158 * paragraph_separation-flag of the text-object.
159 * BUT: parindent is only thrown away, if a parskip is defined! So if you
160 * want a space between the paragraphs and a parindent at the same time,
161 * you should set parskip to zero and use topsep, parsep and bottomsep.
163 * The standard layout is an exception: its parindent is only set, if the
164 * previous paragraph is standard too. Well, this is LateX and it is good!
168 /// Attributes of a layout/paragraph environment
178 bool Read (LyXLex &, LyXTextClass const &);
179 void readAlign(LyXLex &);
180 void readAlignPossible(LyXLex &);
181 void readLabelType(LyXLex &);
182 void readMargin(LyXLex &);
183 void readLatexType(LyXLex &);
184 void readSpacing(LyXLex &);
185 string const & name() const { return name_; }
186 void name(string const & n) { name_ = n; }
187 string const & obsoleted_by() const { return obsoleted_by_; }
188 string const & latexname() const { return latexname_; }
189 string const & labelstring() const { return labelstring_; }
190 string const & preamble() const { return preamble_; }
191 string const & latexparam() const { return latexparam_; }
192 string const & labelstring_appendix() const {
193 return labelstring_appendix_;
195 /** Default font for this layout/environment.
196 The main font for this kind of environment. If an attribute has
197 LyXFont::INHERITED_*, it means that the value is specified by
198 the defaultfont for the entire layout. If we are nested, the
199 font is inherited from the font in the environment one level
200 up until the font is resolved. The values LyXFont::IGNORE_*
201 and LyXFont::TOGGLE are illegal here.
205 /** Default font for labels.
206 Interpretation the same as for font above
210 /** Resolved version of the font for this layout/environment.
211 This is a resolved version the default font. The font is resolved
212 against the defaultfont of the entire layout.
216 /** Resolved version of the font used for labels.
217 This is a resolved version the label font. The font is resolved
218 against the defaultfont of the entire layout.
220 LyXFont reslabelfont;
222 /// Text that dictates how wide the left margin is on the screen
225 /// Text that dictates how wide the right margin is on the screen
228 /// Text that dictates how much space to leave after a potential label
231 /// Text that dictates how much space to leave before a potential label
234 /** Text that dictates the width of the indentation of
252 float labelbottomsep;
261 LyXAlignment align; // add approp. signedness
264 LyXAlignment alignpossible; // add approp. signedness
267 char labeltype; // add approp. signedness
270 char margintype; // add approp. signedness
279 bool newline_allowed;
286 /// true when the fragile commands in the paragraph need to be
289 /// true when empty paragraphs should be kept.
292 bool isParagraph() const {
293 return latextype == LATEX_PARAGRAPH;
296 bool isCommand() const {
297 return latextype == LATEX_COMMAND;
300 bool isEnvironment() const {
301 return (latextype == LATEX_ENVIRONMENT
302 || latextype == LATEX_ITEM_ENVIRONMENT
303 || latextype == LATEX_LIST_ENVIRONMENT);
305 /// Type of LaTeX object
306 LYX_LATEX_TYPES latextype;
307 /// Does this object belong in the title part of the document?
310 /// Name of the layout/paragraph environment
313 /** Name of an layout that has replaced this layout.
314 This is used to rename a layout, while keeping backward
317 string obsoleted_by_;
319 /// LaTeX name for environment
322 /// Label string. "Abstract", "Reference", "Caption"...
325 /// Label string inside appendix. "Appendix", ...
326 string labelstring_appendix_;
328 /// LaTeX parameter for environment
331 /// Macro definitions needed for this layout
340 typedef vector<LyXLayout> LayoutList;
343 LyXTextClass (string const & = string(),
344 string const & = string(),
345 string const & = string());
348 LayoutList::const_iterator begin() const { return layoutlist.begin(); }
350 LayoutList::const_iterator end() const { return layoutlist.end(); }
353 bool Read(string const & filename, bool merge = false);
354 void readOutputType(LyXLex &);
355 void readMaxCounter(LyXLex &);
356 void readClassOptions(LyXLex &);
358 bool hasLayout(string const & name) const;
361 LyXLayout const & GetLayout(string const & vname) const;
364 LyXLayout & GetLayout(string const & vname);
366 /// Sees to that the textclass structure has been loaded
370 string const & name() const { return name_; }
372 string const & latexname() const { return latexname_; }
374 string const & description() const { return description_; }
376 string const & opt_fontsize() const { return opt_fontsize_; }
378 string const & opt_pagestyle() const { return opt_pagestyle_; }
380 string const & options() const { return options_; }
382 string const & pagestyle() const { return pagestyle_; }
384 string const & preamble() const { return preamble_; }
386 /// Packages that are already loaded by the class
393 bool provides(Provides p) const { return provides_ & p; }
396 unsigned int columns() const { return columns_; }
403 PageSides sides() const { return sides_; }
405 int secnumdepth() const { return secnumdepth_; }
407 int tocdepth() const { return tocdepth_; }
410 OutputType outputType() const { return outputType_; }
413 LyXFont const & defaultfont() const { return defaultfont_; }
415 /// Text that dictates how wide the left margin is on the screen
416 string const & leftmargin() const { return leftmargin_; }
418 /// Text that dictates how wide the right margin is on the screen
419 string const & rightmargin() const { return rightmargin_; }
421 int maxcounter() const { return maxcounter_; }
423 LayoutList::size_type numLayouts() const { return layoutlist.size(); }
425 LyXLayout const & operator[](LayoutList::size_type i) const {
426 return layoutlist[i];
430 bool delete_layout(string const &);
432 bool do_readStyle(LyXLex &, LyXLayout &);
439 /// Specific class options
440 string opt_fontsize_;
442 string opt_pagestyle_;
452 unsigned int columns_;
460 OutputType outputType_;
461 /** Base font. The paragraph and layout fonts are resolved against
462 this font. This has to be fully instantiated. Attributes
463 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
466 LyXFont defaultfont_;
467 /// Text that dictates how wide the left margin is on the screen
470 /// Text that dictates how wide the right margin is on the screen
473 int maxcounter_; // add approp. signedness
476 LayoutList layoutlist;
478 /// Has this layout file been loaded yet?
484 inline void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
486 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
491 inline ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
494 case LyXTextClass::OneSide:
497 case LyXTextClass::TwoSides:
506 class LyXTextClassList {
509 typedef vector<LyXTextClass> ClassList;
510 /// Gets layout structure from layout number and textclass number
511 LyXLayout const & Style(ClassList::size_type textclass,
512 LyXTextClass::LayoutList::size_type layout) const;
514 /// Gets layout number from textclass number and layout name
515 pair<bool, LyXTextClass::LayoutList::size_type>
516 NumberOfLayout(ClassList::size_type textclass,
517 string const & name) const;
519 /// Gets a layout name from layout number and textclass number
521 NameOfLayout(ClassList::size_type textclass,
522 LyXTextClass::LayoutList::size_type layout) const;
524 /** Gets textclass number from name.
525 Returns -1 if textclass name does not exist
527 pair<bool, ClassList::size_type>
528 NumberOfClass(string const & textclass) const;
531 string const & NameOfClass(ClassList::size_type number) const;
534 string const & LatexnameOfClass(ClassList::size_type number) const;
537 string const & DescOfClass(ClassList::size_type number) const;
540 LyXTextClass const & TextClass(ClassList::size_type textclass) const;
542 /** Read textclass list.
543 Returns false if this fails
548 Returns false if this fails
550 bool Load(ClassList::size_type number) const;
553 mutable ClassList classlist;
555 void Add (LyXTextClass const &);
558 /// Should not be declared here!! (Lgb) Why not? (Asger)
559 extern LyXTextClassList textclasslist;