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
72 LYX_DIR_LEFT_TO_RIGHT = 1,
74 LYX_DIR_RIGHT_TO_LEFT = -1
90 LYX_ALIGN_LAYOUT = 16,
92 LYX_ALIGN_SPECIAL = 32
96 inline void operator|=(LyXAlignment & la1, LyXAlignment la2) {
97 la1 = static_cast<LyXAlignment>(la1 | la2);
100 /// The different LaTeX-Types
101 enum LYX_LATEX_TYPES {
109 LATEX_ITEM_ENVIRONMENT,
111 LATEX_LIST_ENVIRONMENT
114 /// The different label types
115 enum LYX_LABEL_TYPES {
123 LABEL_TOP_ENVIRONMENT,
125 LABEL_CENTERED_TOP_ENVIRONMENT,
127 // the flushright labels following now must start with LABEL_STATIC
133 LABEL_COUNTER_CHAPTER,
135 LABEL_COUNTER_SECTION,
137 LABEL_COUNTER_SUBSECTION,
139 LABEL_COUNTER_SUBSUBSECTION,
141 LABEL_COUNTER_PARAGRAPH,
143 LABEL_COUNTER_SUBPARAGRAPH,
147 LABEL_COUNTER_ENUMII,
149 LABEL_COUNTER_ENUMIII,
151 LABEL_COUNTER_ENUMIV,
153 LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
157 /* Fix labels are printed flushright, manual labels flushleft.
158 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
159 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
160 * This seems a funny restriction, but I think other combinations are
161 * not needed, so I will not change it yet.
162 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
166 /* There is a parindent and a parskip. Which one is used depends on the
167 * paragraph_separation-flag of the text-object.
168 * BUT: parindent is only thrown away, if a parskip is defined! So if you
169 * want a space between the paragraphs and a parindent at the same time,
170 * you should set parskip to zero and use topsep, parsep and bottomsep.
172 * The standard layout is an exception: its parindent is only set, if the
173 * previous paragraph is standard too. Well, this is LateX and it is good!
177 /// Attributes of a layout/paragraph environment
187 bool Read (LyXLex &, LyXTextClass const &);
188 void readAlign(LyXLex &);
189 void readAlignPossible(LyXLex &);
190 void readLabelType(LyXLex &);
191 void readMargin(LyXLex &);
192 void readLatexType(LyXLex &);
193 void readSpacing(LyXLex &);
194 string const & name() const { return name_; }
195 void name(string const & n) { name_ = n; }
196 string const & obsoleted_by() const { return obsoleted_by_; }
197 string const & latexname() const { return latexname_; }
198 string const & labelstring() const { return labelstring_; }
199 string const & preamble() const { return preamble_; }
200 string const & latexparam() const { return latexparam_; }
201 string const & labelstring_appendix() const {
202 return labelstring_appendix_;
204 /** Default font for this layout/environment.
205 The main font for this kind of environment. If an attribute has
206 LyXFont::INHERITED_*, it means that the value is specified by
207 the defaultfont for the entire layout. If we are nested, the
208 font is inherited from the font in the environment one level
209 up until the font is resolved. The values LyXFont::IGNORE_*
210 and LyXFont::TOGGLE are illegal here.
214 /** Default font for labels.
215 Interpretation the same as for font above
219 /** Resolved version of the font for this layout/environment.
220 This is a resolved version the default font. The font is resolved
221 against the defaultfont of the entire layout.
225 /** Resolved version of the font used for labels.
226 This is a resolved version the label font. The font is resolved
227 against the defaultfont of the entire layout.
229 LyXFont reslabelfont;
231 /// Text that dictates how wide the left margin is on the screen
234 /// Text that dictates how wide the right margin is on the screen
237 /// Text that dictates how much space to leave after a potential label
240 /// Text that dictates how much space to leave before a potential label
243 /** Text that dictates the width of the indentation of
261 float labelbottomsep;
273 LyXAlignment alignpossible;
276 char labeltype; // add approp. type
279 char margintype; // add approp. type
288 bool newline_allowed;
295 /// true when the fragile commands in the paragraph need to be
298 /// true when empty paragraphs should be kept.
301 bool isParagraph() const {
302 return latextype == LATEX_PARAGRAPH;
305 bool isCommand() const {
306 return latextype == LATEX_COMMAND;
309 bool isEnvironment() const {
310 return (latextype == LATEX_ENVIRONMENT
311 || latextype == LATEX_ITEM_ENVIRONMENT
312 || latextype == LATEX_LIST_ENVIRONMENT);
314 /// Type of LaTeX object
315 LYX_LATEX_TYPES latextype;
316 /// Does this object belong in the title part of the document?
319 /// Name of the layout/paragraph environment
322 /** Name of an layout that has replaced this layout.
323 This is used to rename a layout, while keeping backward
326 string obsoleted_by_;
328 /// LaTeX name for environment
331 /// Label string. "Abstract", "Reference", "Caption"...
334 /// Label string inside appendix. "Appendix", ...
335 string labelstring_appendix_;
337 /// LaTeX parameter for environment
340 /// Macro definitions needed for this layout
349 typedef vector<LyXLayout> LayoutList;
351 typedef LayoutList::const_iterator const_iterator;
353 typedef LayoutList::size_type size_type;
355 LyXTextClass (string const & = string(),
356 string const & = string(),
357 string const & = string());
360 const_iterator begin() const { return layoutlist.begin(); }
362 const_iterator end() const { return layoutlist.end(); }
365 bool Read(string const & filename, bool merge = false);
366 void readOutputType(LyXLex &);
367 void readMaxCounter(LyXLex &);
368 void readClassOptions(LyXLex &);
370 bool hasLayout(string const & name) const;
373 LyXLayout const & GetLayout(string const & vname) const;
376 LyXLayout & GetLayout(string const & vname);
378 /// Sees to that the textclass structure has been loaded
382 string const & name() const { return name_; }
384 string const & latexname() const { return latexname_; }
386 string const & description() const { return description_; }
388 string const & opt_fontsize() const { return opt_fontsize_; }
390 string const & opt_pagestyle() const { return opt_pagestyle_; }
392 string const & options() const { return options_; }
394 string const & pagestyle() const { return pagestyle_; }
396 string const & preamble() const { return preamble_; }
398 /// Packages that are already loaded by the class
405 bool provides(Provides p) const { return provides_ & p; }
408 unsigned int columns() const { return columns_; }
415 PageSides sides() const { return sides_; }
417 int secnumdepth() const { return secnumdepth_; }
419 int tocdepth() const { return tocdepth_; }
422 OutputType outputType() const { return outputType_; }
425 LyXFont const & defaultfont() const { return defaultfont_; }
427 /// Text that dictates how wide the left margin is on the screen
428 string const & leftmargin() const { return leftmargin_; }
430 /// Text that dictates how wide the right margin is on the screen
431 string const & rightmargin() const { return rightmargin_; }
433 int maxcounter() const { return maxcounter_; }
435 size_type numLayouts() const { return layoutlist.size(); }
437 LyXLayout const & operator[](size_type i) const {
438 return layoutlist[i];
442 bool delete_layout(string const &);
444 bool do_readStyle(LyXLex &, LyXLayout &);
451 /// Specific class options
452 string opt_fontsize_;
454 string opt_pagestyle_;
464 unsigned int columns_;
472 OutputType outputType_;
473 /** Base font. The paragraph and layout fonts are resolved against
474 this font. This has to be fully instantiated. Attributes
475 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
478 LyXFont defaultfont_;
479 /// Text that dictates how wide the left margin is on the screen
482 /// Text that dictates how wide the right margin is on the screen
485 int maxcounter_; // add approp. signedness
488 LayoutList layoutlist;
490 /// Has this layout file been loaded yet?
496 inline void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
498 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
503 inline ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
506 case LyXTextClass::OneSide:
509 case LyXTextClass::TwoSides:
518 class LyXTextClassList {
521 typedef vector<LyXTextClass> ClassList;
523 typedef ClassList::const_iterator const_iterator;
525 typedef ClassList::size_type size_type;
527 const_iterator begin() const { return classlist.begin(); }
529 const_iterator end() const { return classlist.end(); }
531 /// Gets layout structure from layout number and textclass number
532 LyXLayout const & Style(size_type textclass,
533 LyXTextClass::size_type layout) const;
535 /// Gets layout number from textclass number and layout name
536 pair<bool, LyXTextClass::size_type>
537 NumberOfLayout(size_type textclass,
538 string const & name) const;
540 /// Gets a layout name from layout number and textclass number
542 NameOfLayout(size_type textclass,
543 LyXTextClass::size_type layout) const;
545 /** Gets textclass number from name.
546 Returns -1 if textclass name does not exist
548 pair<bool, size_type>
549 NumberOfClass(string const & textclass) const;
552 string const & NameOfClass(size_type number) const;
555 string const & LatexnameOfClass(size_type number) const;
558 string const & DescOfClass(size_type number) const;
561 LyXTextClass const & TextClass(size_type textclass) const;
563 /** Read textclass list.
564 Returns false if this fails
569 Returns false if this fails
571 bool Load(size_type number) const;
574 mutable ClassList classlist;
576 void Add (LyXTextClass const &);
579 /// Should not be declared here!! (Lgb) Why not? (Asger)
580 extern LyXTextClassList textclasslist;