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 * ====================================================== */
23 #include "support/types.h"
24 #include <boost/utility.hpp>
28 /// Reads the style files
29 extern void LyXSetStyle();
33 LYX_LAYOUT_DEFAULT = 99
36 // Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has
37 // the same value? (Lgb)
39 #define LYX_DUMMY_LAYOUT 99
42 /// The different output types
55 /// The different margin types
56 enum LYX_MARGIN_TYPE {
66 MARGIN_RIGHT_ADDRESS_BOX
83 LYX_ALIGN_LAYOUT = 16,
85 LYX_ALIGN_SPECIAL = 32
90 void operator|=(LyXAlignment & la1, LyXAlignment la2) {
91 la1 = static_cast<LyXAlignment>(la1 | la2);
95 /// The different LaTeX-Types
96 enum LYX_LATEX_TYPES {
104 LATEX_ITEM_ENVIRONMENT,
106 LATEX_LIST_ENVIRONMENT
110 /// The different label types
111 enum LYX_LABEL_TYPES {
119 LABEL_TOP_ENVIRONMENT,
121 LABEL_CENTERED_TOP_ENVIRONMENT,
123 // the flushright labels following now must start with LABEL_STATIC
129 LABEL_COUNTER_CHAPTER,
131 LABEL_COUNTER_SECTION,
133 LABEL_COUNTER_SUBSECTION,
135 LABEL_COUNTER_SUBSUBSECTION,
137 LABEL_COUNTER_PARAGRAPH,
139 LABEL_COUNTER_SUBPARAGRAPH,
143 LABEL_COUNTER_ENUMII,
145 LABEL_COUNTER_ENUMIII,
152 enum LYX_END_LABEL_TYPES {
158 END_LABEL_FILLED_BOX,
162 END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
164 END_LABEL_ENUM_LAST = END_LABEL_STATIC
167 /* Fix labels are printed flushright, manual labels flushleft.
168 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
169 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
170 * This seems a funny restriction, but I think other combinations are
171 * not needed, so I will not change it yet.
172 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
176 /* There is a parindent and a parskip. Which one is used depends on the
177 * paragraph_separation-flag of the text-object.
178 * BUT: parindent is only thrown away, if a parskip is defined! So if you
179 * want a space between the paragraphs and a parindent at the same time,
180 * you should set parskip to zero and use topsep, parsep and bottomsep.
182 * The standard layout is an exception: its parindent is only set, if the
183 * previous paragraph is standard too. Well, this is LateX and it is good!
187 // Attributes of a layout/paragraph environment
197 bool Read (LyXLex &, LyXTextClass const &);
199 void readAlign(LyXLex &);
201 void readAlignPossible(LyXLex &);
203 void readLabelType(LyXLex &);
205 void readEndLabelType(LyXLex &);
207 void readMargin(LyXLex &);
209 void readLatexType(LyXLex &);
211 void readSpacing(LyXLex &);
213 string const & name() const { return name_; }
215 void setName(string const & n) { name_ = n; }
217 string const & obsoleted_by() const { return obsoleted_by_; }
219 string const & latexname() const { return latexname_; }
221 string const & labelstring() const { return labelstring_; }
223 string const & endlabelstring() const { return endlabelstring_; }
225 string const & preamble() const { return preamble_; }
227 string const & latexparam() const { return latexparam_; }
229 string const & labelstring_appendix() const {
230 return labelstring_appendix_;
232 /** Default font for this layout/environment.
233 The main font for this kind of environment. If an attribute has
234 LyXFont::INHERITED_*, it means that the value is specified by
235 the defaultfont for the entire layout. If we are nested, the
236 font is inherited from the font in the environment one level
237 up until the font is resolved. The values LyXFont::IGNORE_*
238 and LyXFont::TOGGLE are illegal here.
242 /** Default font for labels.
243 Interpretation the same as for font above
247 /** Resolved version of the font for this layout/environment.
248 This is a resolved version the default font. The font is resolved
249 against the defaultfont of the entire layout.
253 /** Resolved version of the font used for labels.
254 This is a resolved version the label font. The font is resolved
255 against the defaultfont of the entire layout.
257 LyXFont reslabelfont;
259 /// Text that dictates how wide the left margin is on the screen
262 /// Text that dictates how wide the right margin is on the screen
265 /// Text that dictates how much space to leave after a potential label
268 /// Text that dictates how much space to leave before a potential label
271 /** Text that dictates the width of the indentation of
289 float labelbottomsep;
301 LyXAlignment alignpossible;
304 char labeltype; // add approp. type
307 LYX_END_LABEL_TYPES endlabeltype;
310 LYX_MARGIN_TYPE margintype;
319 bool newline_allowed;
330 /** true when the fragile commands in the paragraph need to be
333 /// true when empty paragraphs should be kept.
336 bool isParagraph() const {
337 return latextype == LATEX_PARAGRAPH;
340 bool isCommand() const {
341 return latextype == LATEX_COMMAND;
344 bool isEnvironment() const {
345 return (latextype == LATEX_ENVIRONMENT
346 || latextype == LATEX_ITEM_ENVIRONMENT
347 || latextype == LATEX_LIST_ENVIRONMENT);
349 /// Type of LaTeX object
350 LYX_LATEX_TYPES latextype;
351 /// Does this object belong in the title part of the document?
354 /// Name of the layout/paragraph environment
357 /** Name of an layout that has replaced this layout.
358 This is used to rename a layout, while keeping backward
361 string obsoleted_by_;
363 /// LaTeX name for environment
366 /// Label string. "Abstract", "Reference", "Caption"...
370 string endlabelstring_;
372 /// Label string inside appendix. "Appendix", ...
373 string labelstring_appendix_;
375 /// LaTeX parameter for environment
378 /// Macro definitions needed for this layout
387 typedef std::vector<LyXLayout> LayoutList;
389 typedef LayoutList::const_iterator const_iterator;
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 lyx::layout_type numLayouts() const { return layoutlist.size(); }
484 LyXLayout const & operator[](lyx::layout_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 const_iterator begin() const { return classlist.begin(); }
563 const_iterator end() const { return classlist.end(); }
565 /// Gets layout structure from layout number and textclass number
566 LyXLayout const & Style(lyx::textclass_type textclass,
567 lyx::layout_type layout) const;
569 /// Gets layout number from textclass number and layout name
570 std::pair<bool, lyx::layout_type> const
571 NumberOfLayout(lyx::textclass_type textclass, string const & name) const;
573 /// Gets a layout name from layout number and textclass number
575 NameOfLayout(lyx::textclass_type textclass, lyx::layout_type layout) const;
577 /** Gets textclass number from name.
578 Returns -1 if textclass name does not exist
580 std::pair<bool, lyx::textclass_type> const
581 NumberOfClass(string const & textclass) const;
584 string const & NameOfClass(lyx::textclass_type number) const;
587 string const & LatexnameOfClass(lyx::textclass_type number) const;
590 string const & DescOfClass(lyx::textclass_type number) const;
593 LyXTextClass const & TextClass(lyx::textclass_type textclass) const;
595 /** Read textclass list.
596 Returns false if this fails
601 Returns false if this fails
603 bool Load(lyx::textclass_type number) const;
606 mutable ClassList classlist;
608 void Add (LyXTextClass const &);
612 extern LyXTextClassList textclasslist;