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 * ====================================================== */
29 /// Reads the style files
30 extern void LyXSetStyle();
33 enum { // no good name for this
35 LYX_ENVIRONMENT_DEFAULT = 97,
37 LYX_LAYOUT_DEFAULT = 99
39 // Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has
40 // the same value? (Lgb)
42 #define LYX_DUMMY_LAYOUT 99
44 /// The different output types
56 /// The different margin types
57 enum LYX_MARGIN_TYPE {
67 MARGIN_RIGHT_ADDRESS_BOX
84 LYX_ALIGN_LAYOUT = 16,
86 LYX_ALIGN_SPECIAL = 32
91 void operator|=(LyXAlignment & la1, LyXAlignment la2) {
92 la1 = static_cast<LyXAlignment>(la1 | la2);
95 /// The different LaTeX-Types
96 enum LYX_LATEX_TYPES {
104 LATEX_ITEM_ENVIRONMENT,
106 LATEX_LIST_ENVIRONMENT
109 /// The different label types
110 enum LYX_LABEL_TYPES {
118 LABEL_TOP_ENVIRONMENT,
120 LABEL_CENTERED_TOP_ENVIRONMENT,
122 // the flushright labels following now must start with LABEL_STATIC
128 LABEL_COUNTER_CHAPTER,
130 LABEL_COUNTER_SECTION,
132 LABEL_COUNTER_SUBSECTION,
134 LABEL_COUNTER_SUBSUBSECTION,
136 LABEL_COUNTER_PARAGRAPH,
138 LABEL_COUNTER_SUBPARAGRAPH,
142 LABEL_COUNTER_ENUMII,
144 LABEL_COUNTER_ENUMIII,
146 LABEL_COUNTER_ENUMIV,
148 LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
151 enum LYX_END_LABEL_TYPES {
157 END_LABEL_FILLED_BOX,
159 END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
161 END_LABEL_ENUM_LAST = END_LABEL_FILLED_BOX
164 /* Fix labels are printed flushright, manual labels flushleft.
165 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
166 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
167 * This seems a funny restriction, but I think other combinations are
168 * not needed, so I will not change it yet.
169 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
173 /* There is a parindent and a parskip. Which one is used depends on the
174 * paragraph_separation-flag of the text-object.
175 * BUT: parindent is only thrown away, if a parskip is defined! So if you
176 * want a space between the paragraphs and a parindent at the same time,
177 * you should set parskip to zero and use topsep, parsep and bottomsep.
179 * The standard layout is an exception: its parindent is only set, if the
180 * previous paragraph is standard too. Well, this is LateX and it is good!
184 /// Attributes of a layout/paragraph environment
194 bool Read (LyXLex &, LyXTextClass const &);
195 void readAlign(LyXLex &);
196 void readAlignPossible(LyXLex &);
197 void readLabelType(LyXLex &);
198 void readEndLabelType(LyXLex &);
199 void readMargin(LyXLex &);
200 void readLatexType(LyXLex &);
201 void readSpacing(LyXLex &);
202 string const & name() const { return name_; }
203 void name(string const & n) { name_ = n; }
204 string const & obsoleted_by() const { return obsoleted_by_; }
205 string const & latexname() const { return latexname_; }
206 string const & labelstring() const { return labelstring_; }
207 string const & preamble() const { return preamble_; }
208 string const & latexparam() const { return latexparam_; }
209 string const & labelstring_appendix() const {
210 return labelstring_appendix_;
212 /** Default font for this layout/environment.
213 The main font for this kind of environment. If an attribute has
214 LyXFont::INHERITED_*, it means that the value is specified by
215 the defaultfont for the entire layout. If we are nested, the
216 font is inherited from the font in the environment one level
217 up until the font is resolved. The values LyXFont::IGNORE_*
218 and LyXFont::TOGGLE are illegal here.
222 /** Default font for labels.
223 Interpretation the same as for font above
227 /** Resolved version of the font for this layout/environment.
228 This is a resolved version the default font. The font is resolved
229 against the defaultfont of the entire layout.
233 /** Resolved version of the font used for labels.
234 This is a resolved version the label font. The font is resolved
235 against the defaultfont of the entire layout.
237 LyXFont reslabelfont;
239 /// Text that dictates how wide the left margin is on the screen
242 /// Text that dictates how wide the right margin is on the screen
245 /// Text that dictates how much space to leave after a potential label
248 /// Text that dictates how much space to leave before a potential label
251 /** Text that dictates the width of the indentation of
269 float labelbottomsep;
281 LyXAlignment alignpossible;
284 char labeltype; // add approp. type
290 LYX_MARGIN_TYPE margintype;
299 bool newline_allowed;
306 /// true when the fragile commands in the paragraph need to be
309 /// true when empty paragraphs should be kept.
312 bool isParagraph() const {
313 return latextype == LATEX_PARAGRAPH;
316 bool isCommand() const {
317 return latextype == LATEX_COMMAND;
320 bool isEnvironment() const {
321 return (latextype == LATEX_ENVIRONMENT
322 || latextype == LATEX_ITEM_ENVIRONMENT
323 || latextype == LATEX_LIST_ENVIRONMENT);
325 /// Type of LaTeX object
326 LYX_LATEX_TYPES latextype;
327 /// Does this object belong in the title part of the document?
330 /// Name of the layout/paragraph environment
333 /** Name of an layout that has replaced this layout.
334 This is used to rename a layout, while keeping backward
337 string obsoleted_by_;
339 /// LaTeX name for environment
342 /// Label string. "Abstract", "Reference", "Caption"...
345 /// Label string inside appendix. "Appendix", ...
346 string labelstring_appendix_;
348 /// LaTeX parameter for environment
351 /// Macro definitions needed for this layout
360 typedef vector<LyXLayout> LayoutList;
362 typedef LayoutList::const_iterator const_iterator;
364 typedef LayoutList::size_type size_type;
366 LyXTextClass (string const & = string(),
367 string const & = string(),
368 string const & = string());
371 const_iterator begin() const { return layoutlist.begin(); }
373 const_iterator end() const { return layoutlist.end(); }
376 bool Read(string const & filename, bool merge = false);
377 void readOutputType(LyXLex &);
378 void readMaxCounter(LyXLex &);
379 void readClassOptions(LyXLex &);
381 bool hasLayout(string const & name) const;
384 LyXLayout const & GetLayout(string const & vname) const;
387 LyXLayout & GetLayout(string const & vname);
389 /// Sees to that the textclass structure has been loaded
393 string const & name() const { return name_; }
395 string const & latexname() const { return latexname_; }
397 string const & description() const { return description_; }
399 string const & opt_fontsize() const { return opt_fontsize_; }
401 string const & opt_pagestyle() const { return opt_pagestyle_; }
403 string const & options() const { return options_; }
405 string const & pagestyle() const { return pagestyle_; }
407 string const & preamble() const { return preamble_; }
409 /// Packages that are already loaded by the class
416 bool provides(Provides p) const { return provides_ & p; }
419 unsigned int columns() const { return columns_; }
426 PageSides sides() const { return sides_; }
428 int secnumdepth() const { return secnumdepth_; }
430 int tocdepth() const { return tocdepth_; }
433 OutputType outputType() const { return outputType_; }
436 LyXFont const & defaultfont() const { return defaultfont_; }
438 /// Text that dictates how wide the left margin is on the screen
439 string const & leftmargin() const { return leftmargin_; }
441 /// Text that dictates how wide the right margin is on the screen
442 string const & rightmargin() const { return rightmargin_; }
444 int maxcounter() const { return maxcounter_; }
446 size_type numLayouts() const { return layoutlist.size(); }
448 LyXLayout const & operator[](size_type i) const {
449 return layoutlist[i];
453 bool delete_layout(string const &);
455 bool do_readStyle(LyXLex &, LyXLayout &);
462 /// Specific class options
463 string opt_fontsize_;
465 string opt_pagestyle_;
475 unsigned int columns_;
483 OutputType outputType_;
484 /** Base font. The paragraph and layout fonts are resolved against
485 this font. This has to be fully instantiated. Attributes
486 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
489 LyXFont defaultfont_;
490 /// Text that dictates how wide the left margin is on the screen
493 /// Text that dictates how wide the right margin is on the screen
496 int maxcounter_; // add approp. signedness
499 LayoutList layoutlist;
501 /// Has this layout file been loaded yet?
508 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
510 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
516 ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
519 case LyXTextClass::OneSide:
522 case LyXTextClass::TwoSides:
531 class LyXTextClassList {
534 typedef vector<LyXTextClass> ClassList;
536 typedef ClassList::const_iterator const_iterator;
538 typedef ClassList::size_type size_type;
540 const_iterator begin() const { return classlist.begin(); }
542 const_iterator end() const { return classlist.end(); }
544 /// Gets layout structure from layout number and textclass number
545 LyXLayout const & Style(size_type textclass,
546 LyXTextClass::size_type layout) const;
548 /// Gets layout number from textclass number and layout name
549 pair<bool, LyXTextClass::size_type>
550 NumberOfLayout(size_type textclass,
551 string const & name) const;
553 /// Gets a layout name from layout number and textclass number
555 NameOfLayout(size_type textclass,
556 LyXTextClass::size_type layout) const;
558 /** Gets textclass number from name.
559 Returns -1 if textclass name does not exist
561 pair<bool, size_type>
562 NumberOfClass(string const & textclass) const;
565 string const & NameOfClass(size_type number) const;
568 string const & LatexnameOfClass(size_type number) const;
571 string const & DescOfClass(size_type number) const;
574 LyXTextClass const & TextClass(size_type textclass) const;
576 /** Read textclass list.
577 Returns false if this fails
582 Returns false if this fails
584 bool Load(size_type number) const;
587 mutable ClassList classlist;
589 void Add (LyXTextClass const &);
592 /// Should not be declared here!! (Lgb) Why not? (Asger)
593 extern LyXTextClassList textclasslist;