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 * ====================================================== */
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
36 // Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has
37 // the same value? (Lgb)
39 #define LYX_DUMMY_LAYOUT 99
41 /// The different output types
53 /// The different margin types
54 enum LYX_MARGIN_TYPE {
64 MARGIN_RIGHT_ADDRESS_BOX
81 LYX_ALIGN_LAYOUT = 16,
83 LYX_ALIGN_SPECIAL = 32
88 void operator|=(LyXAlignment & la1, LyXAlignment la2) {
89 la1 = static_cast<LyXAlignment>(la1 | la2);
92 /// The different LaTeX-Types
93 enum LYX_LATEX_TYPES {
101 LATEX_ITEM_ENVIRONMENT,
103 LATEX_LIST_ENVIRONMENT
106 /// The different label types
107 enum LYX_LABEL_TYPES {
115 LABEL_TOP_ENVIRONMENT,
117 LABEL_CENTERED_TOP_ENVIRONMENT,
119 // the flushright labels following now must start with LABEL_STATIC
125 LABEL_COUNTER_CHAPTER,
127 LABEL_COUNTER_SECTION,
129 LABEL_COUNTER_SUBSECTION,
131 LABEL_COUNTER_SUBSUBSECTION,
133 LABEL_COUNTER_PARAGRAPH,
135 LABEL_COUNTER_SUBPARAGRAPH,
139 LABEL_COUNTER_ENUMII,
141 LABEL_COUNTER_ENUMIII,
146 enum LYX_END_LABEL_TYPES {
152 END_LABEL_FILLED_BOX,
156 END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
158 END_LABEL_ENUM_LAST = END_LABEL_STATIC
161 /* Fix labels are printed flushright, manual labels flushleft.
162 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
163 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
164 * This seems a funny restriction, but I think other combinations are
165 * not needed, so I will not change it yet.
166 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
170 /* There is a parindent and a parskip. Which one is used depends on the
171 * paragraph_separation-flag of the text-object.
172 * BUT: parindent is only thrown away, if a parskip is defined! So if you
173 * want a space between the paragraphs and a parindent at the same time,
174 * you should set parskip to zero and use topsep, parsep and bottomsep.
176 * The standard layout is an exception: its parindent is only set, if the
177 * previous paragraph is standard too. Well, this is LateX and it is good!
181 /// Attributes of a layout/paragraph environment
191 bool Read (LyXLex &, LyXTextClass const &);
192 void readAlign(LyXLex &);
193 void readAlignPossible(LyXLex &);
194 void readLabelType(LyXLex &);
195 void readEndLabelType(LyXLex &);
196 void readMargin(LyXLex &);
197 void readLatexType(LyXLex &);
198 void readSpacing(LyXLex &);
199 string const & name() const { return name_; }
200 void name(string const & n) { name_ = n; }
201 string const & obsoleted_by() const { return obsoleted_by_; }
202 string const & latexname() const { return latexname_; }
203 string const & labelstring() const { return labelstring_; }
204 string const & endlabelstring() const { return endlabelstring_; }
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"...
344 string endlabelstring_;
346 /// Label string inside appendix. "Appendix", ...
347 string labelstring_appendix_;
349 /// LaTeX parameter for environment
352 /// Macro definitions needed for this layout
361 typedef std::vector<LyXLayout> LayoutList;
363 typedef LayoutList::const_iterator const_iterator;
365 typedef LayoutList::size_type size_type;
368 LyXTextClass (string const & = string(),
369 string const & = string(),
370 string const & = string());
373 const_iterator begin() const { return layoutlist.begin(); }
375 const_iterator end() const { return layoutlist.end(); }
378 bool Read(string const & filename, bool merge = false);
379 void readOutputType(LyXLex &);
380 void readMaxCounter(LyXLex &);
381 void readClassOptions(LyXLex &);
383 bool hasLayout(string const & name) const;
386 LyXLayout const & GetLayout(string const & vname) const;
389 LyXLayout & GetLayout(string const & vname);
391 /// Sees to that the textclass structure has been loaded
395 string const & name() const { return name_; }
397 string const & latexname() const { return latexname_; }
399 string const & description() const { return description_; }
401 string const & opt_fontsize() const { return opt_fontsize_; }
403 string const & opt_pagestyle() const { return opt_pagestyle_; }
405 string const & options() const { return options_; }
407 string const & pagestyle() const { return pagestyle_; }
409 string const & preamble() const { return preamble_; }
411 /// Packages that are already loaded by the class
418 bool provides(Provides p) const { return provides_ & p; }
421 unsigned int columns() const { return columns_; }
428 PageSides sides() const { return sides_; }
430 int secnumdepth() const { return secnumdepth_; }
432 int tocdepth() const { return tocdepth_; }
435 OutputType outputType() const { return outputType_; }
438 LyXFont const & defaultfont() const { return defaultfont_; }
440 /// Text that dictates how wide the left margin is on the screen
441 string const & leftmargin() const { return leftmargin_; }
443 /// Text that dictates how wide the right margin is on the screen
444 string const & rightmargin() const { return rightmargin_; }
446 int maxcounter() const { return maxcounter_; }
448 size_type numLayouts() const { return layoutlist.size(); }
450 LyXLayout const & operator[](size_type i) const {
451 return layoutlist[i];
455 bool delete_layout(string const &);
457 bool do_readStyle(LyXLex &, LyXLayout &);
464 /// Specific class options
465 string opt_fontsize_;
467 string opt_pagestyle_;
477 unsigned int columns_;
485 OutputType outputType_;
486 /** Base font. The paragraph and layout fonts are resolved against
487 this font. This has to be fully instantiated. Attributes
488 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
491 LyXFont defaultfont_;
492 /// Text that dictates how wide the left margin is on the screen
495 /// Text that dictates how wide the right margin is on the screen
498 int maxcounter_; // add approp. signedness
501 LayoutList layoutlist;
503 /// Has this layout file been loaded yet?
509 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
511 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
516 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
520 class LyXTextClassList {
523 typedef std::vector<LyXTextClass> ClassList;
525 typedef ClassList::const_iterator const_iterator;
527 typedef ClassList::size_type size_type;
529 const_iterator begin() const { return classlist.begin(); }
531 const_iterator end() const { return classlist.end(); }
533 /// Gets layout structure from layout number and textclass number
534 LyXLayout const & Style(size_type textclass,
535 LyXTextClass::size_type layout) const;
537 /// Gets layout number from textclass number and layout name
538 std::pair<bool, LyXTextClass::size_type>
539 NumberOfLayout(size_type textclass,
540 string const & name) const;
542 /// Gets a layout name from layout number and textclass number
544 NameOfLayout(size_type textclass,
545 LyXTextClass::size_type layout) const;
547 /** Gets textclass number from name.
548 Returns -1 if textclass name does not exist
550 std::pair<bool, size_type>
551 NumberOfClass(string const & textclass) const;
554 string const & NameOfClass(size_type number) const;
557 string const & LatexnameOfClass(size_type number) const;
560 string const & DescOfClass(size_type number) const;
563 LyXTextClass const & TextClass(size_type textclass) const;
565 /** Read textclass list.
566 Returns false if this fails
571 Returns false if this fails
573 bool Load(size_type number) const;
576 mutable ClassList classlist;
578 void Add (LyXTextClass const &);
581 /// Should not be declared here!! (Lgb) Why not? (Asger)
582 extern LyXTextClassList textclasslist;