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
82 LYX_ALIGN_LAYOUT = 16,
84 LYX_ALIGN_SPECIAL = 32
89 void operator|=(LyXAlignment & la1, LyXAlignment la2) {
90 la1 = static_cast<LyXAlignment>(la1 | la2);
93 /// The different LaTeX-Types
94 enum LYX_LATEX_TYPES {
102 LATEX_ITEM_ENVIRONMENT,
104 LATEX_LIST_ENVIRONMENT
107 /// The different label types
108 enum LYX_LABEL_TYPES {
116 LABEL_TOP_ENVIRONMENT,
118 LABEL_CENTERED_TOP_ENVIRONMENT,
120 // the flushright labels following now must start with LABEL_STATIC
126 LABEL_COUNTER_CHAPTER,
128 LABEL_COUNTER_SECTION,
130 LABEL_COUNTER_SUBSECTION,
132 LABEL_COUNTER_SUBSUBSECTION,
134 LABEL_COUNTER_PARAGRAPH,
136 LABEL_COUNTER_SUBPARAGRAPH,
140 LABEL_COUNTER_ENUMII,
142 LABEL_COUNTER_ENUMIII,
144 LABEL_COUNTER_ENUMIV,
146 LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
150 /* Fix labels are printed flushright, manual labels flushleft.
151 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
152 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
153 * This seems a funny restriction, but I think other combinations are
154 * not needed, so I will not change it yet.
155 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
159 /* There is a parindent and a parskip. Which one is used depends on the
160 * paragraph_separation-flag of the text-object.
161 * BUT: parindent is only thrown away, if a parskip is defined! So if you
162 * want a space between the paragraphs and a parindent at the same time,
163 * you should set parskip to zero and use topsep, parsep and bottomsep.
165 * The standard layout is an exception: its parindent is only set, if the
166 * previous paragraph is standard too. Well, this is LateX and it is good!
170 /// Attributes of a layout/paragraph environment
180 bool Read (LyXLex &, LyXTextClass const &);
181 void readAlign(LyXLex &);
182 void readAlignPossible(LyXLex &);
183 void readLabelType(LyXLex &);
184 void readMargin(LyXLex &);
185 void readLatexType(LyXLex &);
186 void readSpacing(LyXLex &);
187 string const & name() const { return name_; }
188 void name(string const & n) { name_ = n; }
189 string const & obsoleted_by() const { return obsoleted_by_; }
190 string const & latexname() const { return latexname_; }
191 string const & labelstring() const { return labelstring_; }
192 string const & preamble() const { return preamble_; }
193 string const & latexparam() const { return latexparam_; }
194 string const & labelstring_appendix() const {
195 return labelstring_appendix_;
197 /** Default font for this layout/environment.
198 The main font for this kind of environment. If an attribute has
199 LyXFont::INHERITED_*, it means that the value is specified by
200 the defaultfont for the entire layout. If we are nested, the
201 font is inherited from the font in the environment one level
202 up until the font is resolved. The values LyXFont::IGNORE_*
203 and LyXFont::TOGGLE are illegal here.
207 /** Default font for labels.
208 Interpretation the same as for font above
212 /** Resolved version of the font for this layout/environment.
213 This is a resolved version the default font. The font is resolved
214 against the defaultfont of the entire layout.
218 /** Resolved version of the font used for labels.
219 This is a resolved version the label font. The font is resolved
220 against the defaultfont of the entire layout.
222 LyXFont reslabelfont;
224 /// Text that dictates how wide the left margin is on the screen
227 /// Text that dictates how wide the right margin is on the screen
230 /// Text that dictates how much space to leave after a potential label
233 /// Text that dictates how much space to leave before a potential label
236 /** Text that dictates the width of the indentation of
254 float labelbottomsep;
266 LyXAlignment alignpossible;
269 char labeltype; // add approp. type
272 LYX_MARGIN_TYPE margintype;
281 bool newline_allowed;
288 /// true when the fragile commands in the paragraph need to be
291 /// true when empty paragraphs should be kept.
294 bool isParagraph() const {
295 return latextype == LATEX_PARAGRAPH;
298 bool isCommand() const {
299 return latextype == LATEX_COMMAND;
302 bool isEnvironment() const {
303 return (latextype == LATEX_ENVIRONMENT
304 || latextype == LATEX_ITEM_ENVIRONMENT
305 || latextype == LATEX_LIST_ENVIRONMENT);
307 /// Type of LaTeX object
308 LYX_LATEX_TYPES latextype;
309 /// Does this object belong in the title part of the document?
312 /// Name of the layout/paragraph environment
315 /** Name of an layout that has replaced this layout.
316 This is used to rename a layout, while keeping backward
319 string obsoleted_by_;
321 /// LaTeX name for environment
324 /// Label string. "Abstract", "Reference", "Caption"...
327 /// Label string inside appendix. "Appendix", ...
328 string labelstring_appendix_;
330 /// LaTeX parameter for environment
333 /// Macro definitions needed for this layout
342 typedef vector<LyXLayout> LayoutList;
344 typedef LayoutList::const_iterator const_iterator;
346 typedef LayoutList::size_type size_type;
348 LyXTextClass (string const & = string(),
349 string const & = string(),
350 string const & = string());
353 const_iterator begin() const { return layoutlist.begin(); }
355 const_iterator end() const { return layoutlist.end(); }
358 bool Read(string const & filename, bool merge = false);
359 void readOutputType(LyXLex &);
360 void readMaxCounter(LyXLex &);
361 void readClassOptions(LyXLex &);
363 bool hasLayout(string const & name) const;
366 LyXLayout const & GetLayout(string const & vname) const;
369 LyXLayout & GetLayout(string const & vname);
371 /// Sees to that the textclass structure has been loaded
375 string const & name() const { return name_; }
377 string const & latexname() const { return latexname_; }
379 string const & description() const { return description_; }
381 string const & opt_fontsize() const { return opt_fontsize_; }
383 string const & opt_pagestyle() const { return opt_pagestyle_; }
385 string const & options() const { return options_; }
387 string const & pagestyle() const { return pagestyle_; }
389 string const & preamble() const { return preamble_; }
391 /// Packages that are already loaded by the class
398 bool provides(Provides p) const { return provides_ & p; }
401 unsigned int columns() const { return columns_; }
408 PageSides sides() const { return sides_; }
410 int secnumdepth() const { return secnumdepth_; }
412 int tocdepth() const { return tocdepth_; }
415 OutputType outputType() const { return outputType_; }
418 LyXFont const & defaultfont() const { return defaultfont_; }
420 /// Text that dictates how wide the left margin is on the screen
421 string const & leftmargin() const { return leftmargin_; }
423 /// Text that dictates how wide the right margin is on the screen
424 string const & rightmargin() const { return rightmargin_; }
426 int maxcounter() const { return maxcounter_; }
428 size_type numLayouts() const { return layoutlist.size(); }
430 LyXLayout const & operator[](size_type i) const {
431 return layoutlist[i];
435 bool delete_layout(string const &);
437 bool do_readStyle(LyXLex &, LyXLayout &);
444 /// Specific class options
445 string opt_fontsize_;
447 string opt_pagestyle_;
457 unsigned int columns_;
465 OutputType outputType_;
466 /** Base font. The paragraph and layout fonts are resolved against
467 this font. This has to be fully instantiated. Attributes
468 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
471 LyXFont defaultfont_;
472 /// Text that dictates how wide the left margin is on the screen
475 /// Text that dictates how wide the right margin is on the screen
478 int maxcounter_; // add approp. signedness
481 LayoutList layoutlist;
483 /// Has this layout file been loaded yet?
490 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
492 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
498 ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
501 case LyXTextClass::OneSide:
504 case LyXTextClass::TwoSides:
513 class LyXTextClassList {
516 typedef vector<LyXTextClass> ClassList;
518 typedef ClassList::const_iterator const_iterator;
520 typedef ClassList::size_type size_type;
522 const_iterator begin() const { return classlist.begin(); }
524 const_iterator end() const { return classlist.end(); }
526 /// Gets layout structure from layout number and textclass number
527 LyXLayout const & Style(size_type textclass,
528 LyXTextClass::size_type layout) const;
530 /// Gets layout number from textclass number and layout name
531 pair<bool, LyXTextClass::size_type>
532 NumberOfLayout(size_type textclass,
533 string const & name) const;
535 /// Gets a layout name from layout number and textclass number
537 NameOfLayout(size_type textclass,
538 LyXTextClass::size_type layout) const;
540 /** Gets textclass number from name.
541 Returns -1 if textclass name does not exist
543 pair<bool, size_type>
544 NumberOfClass(string const & textclass) const;
547 string const & NameOfClass(size_type number) const;
550 string const & LatexnameOfClass(size_type number) const;
553 string const & DescOfClass(size_type number) const;
556 LyXTextClass const & TextClass(size_type textclass) const;
558 /** Read textclass list.
559 Returns false if this fails
564 Returns false if this fails
566 bool Load(size_type number) const;
569 mutable ClassList classlist;
571 void Add (LyXTextClass const &);
574 /// Should not be declared here!! (Lgb) Why not? (Asger)
575 extern LyXTextClassList textclasslist;