2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-2001 The LyX Team.
10 * ====================================================== */
24 #include <boost/utility.hpp>
26 /// Reads the style files
27 extern void LyXSetStyle();
30 enum no_good_name_for_this {
32 LYX_ENVIRONMENT_DEFAULT = 97,
34 LYX_LAYOUT_DEFAULT = 99
38 // Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has
39 // the same value? (Lgb)
41 #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,
150 enum LYX_END_LABEL_TYPES {
156 END_LABEL_FILLED_BOX,
160 END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
162 END_LABEL_ENUM_LAST = END_LABEL_STATIC
165 /* Fix labels are printed flushright, manual labels flushleft.
166 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
167 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
168 * This seems a funny restriction, but I think other combinations are
169 * not needed, so I will not change it yet.
170 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
174 /* There is a parindent and a parskip. Which one is used depends on the
175 * paragraph_separation-flag of the text-object.
176 * BUT: parindent is only thrown away, if a parskip is defined! So if you
177 * want a space between the paragraphs and a parindent at the same time,
178 * you should set parskip to zero and use topsep, parsep and bottomsep.
180 * The standard layout is an exception: its parindent is only set, if the
181 * previous paragraph is standard too. Well, this is LateX and it is good!
185 // Attributes of a layout/paragraph environment
195 bool Read (LyXLex &, LyXTextClass const &);
197 void readAlign(LyXLex &);
199 void readAlignPossible(LyXLex &);
201 void readLabelType(LyXLex &);
203 void readEndLabelType(LyXLex &);
205 void readMargin(LyXLex &);
207 void readLatexType(LyXLex &);
209 void readSpacing(LyXLex &);
211 string const & name() const { return name_; }
213 void setName(string const & n) { name_ = n; }
215 string const & obsoleted_by() const { return obsoleted_by_; }
217 string const & latexname() const { return latexname_; }
219 string const & labelstring() const { return labelstring_; }
221 string const & endlabelstring() const { return endlabelstring_; }
223 string const & preamble() const { return preamble_; }
225 string const & latexparam() const { return latexparam_; }
227 string const & labelstring_appendix() const {
228 return labelstring_appendix_;
230 /** Default font for this layout/environment.
231 The main font for this kind of environment. If an attribute has
232 LyXFont::INHERITED_*, it means that the value is specified by
233 the defaultfont for the entire layout. If we are nested, the
234 font is inherited from the font in the environment one level
235 up until the font is resolved. The values LyXFont::IGNORE_*
236 and LyXFont::TOGGLE are illegal here.
240 /** Default font for labels.
241 Interpretation the same as for font above
245 /** Resolved version of the font for this layout/environment.
246 This is a resolved version the default font. The font is resolved
247 against the defaultfont of the entire layout.
251 /** Resolved version of the font used for labels.
252 This is a resolved version the label font. The font is resolved
253 against the defaultfont of the entire layout.
255 LyXFont reslabelfont;
257 /// Text that dictates how wide the left margin is on the screen
260 /// Text that dictates how wide the right margin is on the screen
263 /// Text that dictates how much space to leave after a potential label
266 /// Text that dictates how much space to leave before a potential label
269 /** Text that dictates the width of the indentation of
287 float labelbottomsep;
299 LyXAlignment alignpossible;
302 char labeltype; // add approp. type
308 LYX_MARGIN_TYPE margintype;
317 bool newline_allowed;
328 /** true when the fragile commands in the paragraph need to be
331 /// true when empty paragraphs should be kept.
334 bool isParagraph() const {
335 return latextype == LATEX_PARAGRAPH;
338 bool isCommand() const {
339 return latextype == LATEX_COMMAND;
342 bool isEnvironment() const {
343 return (latextype == LATEX_ENVIRONMENT
344 || latextype == LATEX_ITEM_ENVIRONMENT
345 || latextype == LATEX_LIST_ENVIRONMENT);
347 /// Type of LaTeX object
348 LYX_LATEX_TYPES latextype;
349 /// Does this object belong in the title part of the document?
352 /// Name of the layout/paragraph environment
355 /** Name of an layout that has replaced this layout.
356 This is used to rename a layout, while keeping backward
359 string obsoleted_by_;
361 /// LaTeX name for environment
364 /// Label string. "Abstract", "Reference", "Caption"...
368 string endlabelstring_;
370 /// Label string inside appendix. "Appendix", ...
371 string labelstring_appendix_;
373 /// LaTeX parameter for environment
376 /// Macro definitions needed for this layout
385 typedef std::vector<LyXLayout> LayoutList;
387 typedef LayoutList::const_iterator const_iterator;
389 typedef LayoutList::size_type size_type;
392 LyXTextClass (string const & = string(),
393 string const & = string(),
394 string const & = string());
397 const_iterator begin() const { return layoutlist.begin(); }
399 const_iterator end() const { return layoutlist.end(); }
402 bool Read(string const & filename, bool merge = false);
404 void readOutputType(LyXLex &);
406 void readMaxCounter(LyXLex &);
408 void readClassOptions(LyXLex &);
410 bool hasLayout(string const & name) const;
413 LyXLayout const & GetLayout(string const & vname) const;
416 LyXLayout & GetLayout(string const & vname);
418 /// Sees to that the textclass structure has been loaded
422 string const & name() const { return name_; }
424 string const & latexname() const { return latexname_; }
426 string const & description() const { return description_; }
428 string const & opt_fontsize() const { return opt_fontsize_; }
430 string const & opt_pagestyle() const { return opt_pagestyle_; }
432 string const & options() const { return options_; }
434 string const & pagestyle() const { return pagestyle_; }
436 string const & preamble() const { return preamble_; }
438 /// Packages that are already loaded by the class
450 bool provides(Provides p) const { return provides_ & p; }
453 unsigned int columns() const { return columns_; }
462 PageSides sides() const { return sides_; }
464 int secnumdepth() const { return secnumdepth_; }
466 int tocdepth() const { return tocdepth_; }
469 OutputType outputType() const { return outputType_; }
472 LyXFont const & defaultfont() const { return defaultfont_; }
474 /// Text that dictates how wide the left margin is on the screen
475 string const & leftmargin() const { return leftmargin_; }
477 /// Text that dictates how wide the right margin is on the screen
478 string const & rightmargin() const { return rightmargin_; }
480 int maxcounter() const { return maxcounter_; }
482 size_type numLayouts() const { return layoutlist.size(); }
484 LyXLayout const & operator[](size_type i) const {
485 return layoutlist[i];
489 bool delete_layout(string const &);
491 bool do_readStyle(LyXLex &, LyXLayout &);
498 /// Specific class options
499 string opt_fontsize_;
501 string opt_pagestyle_;
511 unsigned int columns_;
519 OutputType outputType_;
520 /** Base font. The paragraph and layout fonts are resolved against
521 this font. This has to be fully instantiated. Attributes
522 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
525 LyXFont defaultfont_;
526 /// Text that dictates how wide the left margin is on the screen
529 /// Text that dictates how wide the right margin is on the screen
532 int maxcounter_; // add approp. signedness
535 LayoutList layoutlist;
537 /// Has this layout file been loaded yet?
543 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
545 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
550 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
554 class LyXTextClassList : boost::noncopyable {
557 typedef std::vector<LyXTextClass> ClassList;
559 typedef ClassList::const_iterator const_iterator;
561 typedef ClassList::size_type size_type;
563 const_iterator begin() const { return classlist.begin(); }
565 const_iterator end() const { return classlist.end(); }
567 /// Gets layout structure from layout number and textclass number
568 LyXLayout const & Style(size_type textclass,
569 LyXTextClass::size_type layout) const;
571 /// Gets layout number from textclass number and layout name
572 std::pair<bool, LyXTextClass::size_type> const
573 NumberOfLayout(size_type textclass,
574 string const & name) const;
576 /// Gets a layout name from layout number and textclass number
578 NameOfLayout(size_type textclass,
579 LyXTextClass::size_type layout) const;
581 /** Gets textclass number from name.
582 Returns -1 if textclass name does not exist
584 std::pair<bool, size_type> const
585 NumberOfClass(string const & textclass) const;
588 string const & NameOfClass(size_type number) const;
591 string const & LatexnameOfClass(size_type number) const;
594 string const & DescOfClass(size_type number) const;
597 LyXTextClass const & TextClass(size_type textclass) const;
599 /** Read textclass list.
600 Returns false if this fails
605 Returns false if this fails
607 bool Load(size_type number) const;
610 mutable ClassList classlist;
612 void Add (LyXTextClass const &);
616 extern LyXTextClassList textclasslist;