2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2000 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
149 enum LYX_END_LABEL_TYPES {
155 END_LABEL_FILLED_BOX,
157 END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
159 END_LABEL_ENUM_LAST = END_LABEL_FILLED_BOX
162 /* Fix labels are printed flushright, manual labels flushleft.
163 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
164 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
165 * This seems a funny restriction, but I think other combinations are
166 * not needed, so I will not change it yet.
167 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
171 /* There is a parindent and a parskip. Which one is used depends on the
172 * paragraph_separation-flag of the text-object.
173 * BUT: parindent is only thrown away, if a parskip is defined! So if you
174 * want a space between the paragraphs and a parindent at the same time,
175 * you should set parskip to zero and use topsep, parsep and bottomsep.
177 * The standard layout is an exception: its parindent is only set, if the
178 * previous paragraph is standard too. Well, this is LateX and it is good!
182 /// Attributes of a layout/paragraph environment
192 bool Read (LyXLex &, LyXTextClass const &);
193 void readAlign(LyXLex &);
194 void readAlignPossible(LyXLex &);
195 void readLabelType(LyXLex &);
196 void readEndLabelType(LyXLex &);
197 void readMargin(LyXLex &);
198 void readLatexType(LyXLex &);
199 void readSpacing(LyXLex &);
200 string const & name() const { return name_; }
201 void name(string const & n) { name_ = n; }
202 string const & obsoleted_by() const { return obsoleted_by_; }
203 string const & latexname() const { return latexname_; }
204 string const & labelstring() const { return labelstring_; }
205 string const & preamble() const { return preamble_; }
206 string const & latexparam() const { return latexparam_; }
207 string const & labelstring_appendix() const {
208 return labelstring_appendix_;
210 /** Default font for this layout/environment.
211 The main font for this kind of environment. If an attribute has
212 LyXFont::INHERITED_*, it means that the value is specified by
213 the defaultfont for the entire layout. If we are nested, the
214 font is inherited from the font in the environment one level
215 up until the font is resolved. The values LyXFont::IGNORE_*
216 and LyXFont::TOGGLE are illegal here.
220 /** Default font for labels.
221 Interpretation the same as for font above
225 /** Resolved version of the font for this layout/environment.
226 This is a resolved version the default font. The font is resolved
227 against the defaultfont of the entire layout.
231 /** Resolved version of the font used for labels.
232 This is a resolved version the label font. The font is resolved
233 against the defaultfont of the entire layout.
235 LyXFont reslabelfont;
237 /// Text that dictates how wide the left margin is on the screen
240 /// Text that dictates how wide the right margin is on the screen
243 /// Text that dictates how much space to leave after a potential label
246 /// Text that dictates how much space to leave before a potential label
249 /** Text that dictates the width of the indentation of
267 float labelbottomsep;
279 LyXAlignment alignpossible;
282 char labeltype; // add approp. type
288 LYX_MARGIN_TYPE margintype;
297 bool newline_allowed;
304 /// true when the fragile commands in the paragraph need to be
307 /// true when empty paragraphs should be kept.
310 bool isParagraph() const {
311 return latextype == LATEX_PARAGRAPH;
314 bool isCommand() const {
315 return latextype == LATEX_COMMAND;
318 bool isEnvironment() const {
319 return (latextype == LATEX_ENVIRONMENT
320 || latextype == LATEX_ITEM_ENVIRONMENT
321 || latextype == LATEX_LIST_ENVIRONMENT);
323 /// Type of LaTeX object
324 LYX_LATEX_TYPES latextype;
325 /// Does this object belong in the title part of the document?
328 /// Name of the layout/paragraph environment
331 /** Name of an layout that has replaced this layout.
332 This is used to rename a layout, while keeping backward
335 string obsoleted_by_;
337 /// LaTeX name for environment
340 /// Label string. "Abstract", "Reference", "Caption"...
343 /// Label string inside appendix. "Appendix", ...
344 string labelstring_appendix_;
346 /// LaTeX parameter for environment
349 /// Macro definitions needed for this layout
358 typedef vector<LyXLayout> LayoutList;
360 typedef LayoutList::const_iterator const_iterator;
362 typedef LayoutList::size_type size_type;
364 LyXTextClass (string const & = string(),
365 string const & = string(),
366 string const & = string());
369 const_iterator begin() const { return layoutlist.begin(); }
371 const_iterator end() const { return layoutlist.end(); }
374 bool Read(string const & filename, bool merge = false);
375 void readOutputType(LyXLex &);
376 void readMaxCounter(LyXLex &);
377 void readClassOptions(LyXLex &);
379 bool hasLayout(string const & name) const;
382 LyXLayout const & GetLayout(string const & vname) const;
385 LyXLayout & GetLayout(string const & vname);
387 /// Sees to that the textclass structure has been loaded
391 string const & name() const { return name_; }
393 string const & latexname() const { return latexname_; }
395 string const & description() const { return description_; }
397 string const & opt_fontsize() const { return opt_fontsize_; }
399 string const & opt_pagestyle() const { return opt_pagestyle_; }
401 string const & options() const { return options_; }
403 string const & pagestyle() const { return pagestyle_; }
405 string const & preamble() const { return preamble_; }
407 /// Packages that are already loaded by the class
414 bool provides(Provides p) const { return provides_ & p; }
417 unsigned int columns() const { return columns_; }
424 PageSides sides() const { return sides_; }
426 int secnumdepth() const { return secnumdepth_; }
428 int tocdepth() const { return tocdepth_; }
431 OutputType outputType() const { return outputType_; }
434 LyXFont const & defaultfont() const { return defaultfont_; }
436 /// Text that dictates how wide the left margin is on the screen
437 string const & leftmargin() const { return leftmargin_; }
439 /// Text that dictates how wide the right margin is on the screen
440 string const & rightmargin() const { return rightmargin_; }
442 int maxcounter() const { return maxcounter_; }
444 size_type numLayouts() const { return layoutlist.size(); }
446 LyXLayout const & operator[](size_type i) const {
447 return layoutlist[i];
451 bool delete_layout(string const &);
453 bool do_readStyle(LyXLex &, LyXLayout &);
460 /// Specific class options
461 string opt_fontsize_;
463 string opt_pagestyle_;
473 unsigned int columns_;
481 OutputType outputType_;
482 /** Base font. The paragraph and layout fonts are resolved against
483 this font. This has to be fully instantiated. Attributes
484 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
487 LyXFont defaultfont_;
488 /// Text that dictates how wide the left margin is on the screen
491 /// Text that dictates how wide the right margin is on the screen
494 int maxcounter_; // add approp. signedness
497 LayoutList layoutlist;
499 /// Has this layout file been loaded yet?
506 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
508 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
514 ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
517 case LyXTextClass::OneSide:
520 case LyXTextClass::TwoSides:
529 class LyXTextClassList {
532 typedef vector<LyXTextClass> ClassList;
534 typedef ClassList::const_iterator const_iterator;
536 typedef ClassList::size_type size_type;
538 const_iterator begin() const { return classlist.begin(); }
540 const_iterator end() const { return classlist.end(); }
542 /// Gets layout structure from layout number and textclass number
543 LyXLayout const & Style(size_type textclass,
544 LyXTextClass::size_type layout) const;
546 /// Gets layout number from textclass number and layout name
547 pair<bool, LyXTextClass::size_type>
548 NumberOfLayout(size_type textclass,
549 string const & name) const;
551 /// Gets a layout name from layout number and textclass number
553 NameOfLayout(size_type textclass,
554 LyXTextClass::size_type layout) const;
556 /** Gets textclass number from name.
557 Returns -1 if textclass name does not exist
559 pair<bool, size_type>
560 NumberOfClass(string const & textclass) const;
563 string const & NameOfClass(size_type number) const;
566 string const & LatexnameOfClass(size_type number) const;
569 string const & DescOfClass(size_type number) const;
572 LyXTextClass const & TextClass(size_type textclass) const;
574 /** Read textclass list.
575 Returns false if this fails
580 Returns false if this fails
582 bool Load(size_type number) const;
585 mutable ClassList classlist;
587 void Add (LyXTextClass const &);
590 /// Should not be declared here!! (Lgb) Why not? (Asger)
591 extern LyXTextClassList textclasslist;