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;
264 LyXAlignment alignpossible;
267 char labeltype; // add approp. type
270 char margintype; // add approp. type
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;
342 typedef LayoutList::const_iterator const_iterator;
344 typedef LayoutList::size_type size_type;
346 LyXTextClass (string const & = string(),
347 string const & = string(),
348 string const & = string());
351 const_iterator begin() const { return layoutlist.begin(); }
353 const_iterator end() const { return layoutlist.end(); }
356 bool Read(string const & filename, bool merge = false);
357 void readOutputType(LyXLex &);
358 void readMaxCounter(LyXLex &);
359 void readClassOptions(LyXLex &);
361 bool hasLayout(string const & name) const;
364 LyXLayout const & GetLayout(string const & vname) const;
367 LyXLayout & GetLayout(string const & vname);
369 /// Sees to that the textclass structure has been loaded
373 string const & name() const { return name_; }
375 string const & latexname() const { return latexname_; }
377 string const & description() const { return description_; }
379 string const & opt_fontsize() const { return opt_fontsize_; }
381 string const & opt_pagestyle() const { return opt_pagestyle_; }
383 string const & options() const { return options_; }
385 string const & pagestyle() const { return pagestyle_; }
387 string const & preamble() const { return preamble_; }
389 /// Packages that are already loaded by the class
396 bool provides(Provides p) const { return provides_ & p; }
399 unsigned int columns() const { return columns_; }
406 PageSides sides() const { return sides_; }
408 int secnumdepth() const { return secnumdepth_; }
410 int tocdepth() const { return tocdepth_; }
413 OutputType outputType() const { return outputType_; }
416 LyXFont const & defaultfont() const { return defaultfont_; }
418 /// Text that dictates how wide the left margin is on the screen
419 string const & leftmargin() const { return leftmargin_; }
421 /// Text that dictates how wide the right margin is on the screen
422 string const & rightmargin() const { return rightmargin_; }
424 int maxcounter() const { return maxcounter_; }
426 size_type numLayouts() const { return layoutlist.size(); }
428 LyXLayout const & operator[](size_type i) const {
429 return layoutlist[i];
433 bool delete_layout(string const &);
435 bool do_readStyle(LyXLex &, LyXLayout &);
442 /// Specific class options
443 string opt_fontsize_;
445 string opt_pagestyle_;
455 unsigned int columns_;
463 OutputType outputType_;
464 /** Base font. The paragraph and layout fonts are resolved against
465 this font. This has to be fully instantiated. Attributes
466 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
469 LyXFont defaultfont_;
470 /// Text that dictates how wide the left margin is on the screen
473 /// Text that dictates how wide the right margin is on the screen
476 int maxcounter_; // add approp. signedness
479 LayoutList layoutlist;
481 /// Has this layout file been loaded yet?
487 inline void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
489 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
494 inline ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
497 case LyXTextClass::OneSide:
500 case LyXTextClass::TwoSides:
509 class LyXTextClassList {
512 typedef vector<LyXTextClass> ClassList;
514 typedef ClassList::const_iterator const_iterator;
516 typedef ClassList::size_type size_type;
518 const_iterator begin() const { return classlist.begin(); }
520 const_iterator end() const { return classlist.end(); }
522 /// Gets layout structure from layout number and textclass number
523 LyXLayout const & Style(size_type textclass,
524 LyXTextClass::size_type layout) const;
526 /// Gets layout number from textclass number and layout name
527 pair<bool, LyXTextClass::size_type>
528 NumberOfLayout(size_type textclass,
529 string const & name) const;
531 /// Gets a layout name from layout number and textclass number
533 NameOfLayout(size_type textclass,
534 LyXTextClass::size_type layout) const;
536 /** Gets textclass number from name.
537 Returns -1 if textclass name does not exist
539 pair<bool, size_type>
540 NumberOfClass(string const & textclass) const;
543 string const & NameOfClass(size_type number) const;
546 string const & LatexnameOfClass(size_type number) const;
549 string const & DescOfClass(size_type number) const;
552 LyXTextClass const & TextClass(size_type textclass) const;
554 /** Read textclass list.
555 Returns false if this fails
560 Returns false if this fails
562 bool Load(size_type number) const;
565 mutable ClassList classlist;
567 void Add (LyXTextClass const &);
570 /// Should not be declared here!! (Lgb) Why not? (Asger)
571 extern LyXTextClassList textclasslist;