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,
143 LABEL_COUNTER_ENUMIV,
145 LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
148 enum LYX_END_LABEL_TYPES {
154 END_LABEL_FILLED_BOX,
158 END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
160 END_LABEL_ENUM_LAST = END_LABEL_STATIC
163 /* Fix labels are printed flushright, manual labels flushleft.
164 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
165 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
166 * This seems a funny restriction, but I think other combinations are
167 * not needed, so I will not change it yet.
168 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
172 /* There is a parindent and a parskip. Which one is used depends on the
173 * paragraph_separation-flag of the text-object.
174 * BUT: parindent is only thrown away, if a parskip is defined! So if you
175 * want a space between the paragraphs and a parindent at the same time,
176 * you should set parskip to zero and use topsep, parsep and bottomsep.
178 * The standard layout is an exception: its parindent is only set, if the
179 * previous paragraph is standard too. Well, this is LateX and it is good!
183 /// Attributes of a layout/paragraph environment
193 bool Read (LyXLex &, LyXTextClass const &);
194 void readAlign(LyXLex &);
195 void readAlignPossible(LyXLex &);
196 void readLabelType(LyXLex &);
197 void readEndLabelType(LyXLex &);
198 void readMargin(LyXLex &);
199 void readLatexType(LyXLex &);
200 void readSpacing(LyXLex &);
201 string const & name() const { return name_; }
202 void name(string const & n) { name_ = n; }
203 string const & obsoleted_by() const { return obsoleted_by_; }
204 string const & latexname() const { return latexname_; }
205 string const & labelstring() const { return labelstring_; }
206 string const & endlabelstring() const { return endlabelstring_; }
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"...
346 string endlabelstring_;
348 /// Label string inside appendix. "Appendix", ...
349 string labelstring_appendix_;
351 /// LaTeX parameter for environment
354 /// Macro definitions needed for this layout
363 typedef std::vector<LyXLayout> LayoutList;
365 typedef LayoutList::const_iterator const_iterator;
367 typedef LayoutList::size_type size_type;
370 LyXTextClass (string const & = string(),
371 string const & = string(),
372 string const & = string());
375 const_iterator begin() const { return layoutlist.begin(); }
377 const_iterator end() const { return layoutlist.end(); }
380 bool Read(string const & filename, bool merge = false);
381 void readOutputType(LyXLex &);
382 void readMaxCounter(LyXLex &);
383 void readClassOptions(LyXLex &);
385 bool hasLayout(string const & name) const;
388 LyXLayout const & GetLayout(string const & vname) const;
391 LyXLayout & GetLayout(string const & vname);
393 /// Sees to that the textclass structure has been loaded
397 string const & name() const { return name_; }
399 string const & latexname() const { return latexname_; }
401 string const & description() const { return description_; }
403 string const & opt_fontsize() const { return opt_fontsize_; }
405 string const & opt_pagestyle() const { return opt_pagestyle_; }
407 string const & options() const { return options_; }
409 string const & pagestyle() const { return pagestyle_; }
411 string const & preamble() const { return preamble_; }
413 /// Packages that are already loaded by the class
420 bool provides(Provides p) const { return provides_ & p; }
423 unsigned int columns() const { return columns_; }
430 PageSides sides() const { return sides_; }
432 int secnumdepth() const { return secnumdepth_; }
434 int tocdepth() const { return tocdepth_; }
437 OutputType outputType() const { return outputType_; }
440 LyXFont const & defaultfont() const { return defaultfont_; }
442 /// Text that dictates how wide the left margin is on the screen
443 string const & leftmargin() const { return leftmargin_; }
445 /// Text that dictates how wide the right margin is on the screen
446 string const & rightmargin() const { return rightmargin_; }
448 int maxcounter() const { return maxcounter_; }
450 size_type numLayouts() const { return layoutlist.size(); }
452 LyXLayout const & operator[](size_type i) const {
453 return layoutlist[i];
457 bool delete_layout(string const &);
459 bool do_readStyle(LyXLex &, LyXLayout &);
466 /// Specific class options
467 string opt_fontsize_;
469 string opt_pagestyle_;
479 unsigned int columns_;
487 OutputType outputType_;
488 /** Base font. The paragraph and layout fonts are resolved against
489 this font. This has to be fully instantiated. Attributes
490 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
493 LyXFont defaultfont_;
494 /// Text that dictates how wide the left margin is on the screen
497 /// Text that dictates how wide the right margin is on the screen
500 int maxcounter_; // add approp. signedness
503 LayoutList layoutlist;
505 /// Has this layout file been loaded yet?
511 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
513 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
518 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
522 class LyXTextClassList {
525 typedef std::vector<LyXTextClass> ClassList;
527 typedef ClassList::const_iterator const_iterator;
529 typedef ClassList::size_type size_type;
531 const_iterator begin() const { return classlist.begin(); }
533 const_iterator end() const { return classlist.end(); }
535 /// Gets layout structure from layout number and textclass number
536 LyXLayout const & Style(size_type textclass,
537 LyXTextClass::size_type layout) const;
539 /// Gets layout number from textclass number and layout name
540 std::pair<bool, LyXTextClass::size_type>
541 NumberOfLayout(size_type textclass,
542 string const & name) const;
544 /// Gets a layout name from layout number and textclass number
546 NameOfLayout(size_type textclass,
547 LyXTextClass::size_type layout) const;
549 /** Gets textclass number from name.
550 Returns -1 if textclass name does not exist
552 std::pair<bool, size_type>
553 NumberOfClass(string const & textclass) const;
556 string const & NameOfClass(size_type number) const;
559 string const & LatexnameOfClass(size_type number) const;
562 string const & DescOfClass(size_type number) const;
565 LyXTextClass const & TextClass(size_type textclass) const;
567 /** Read textclass list.
568 Returns false if this fails
573 Returns false if this fails
575 bool Load(size_type number) const;
578 mutable ClassList classlist;
580 void Add (LyXTextClass const &);
583 /// Should not be declared here!! (Lgb) Why not? (Asger)
584 extern LyXTextClassList textclasslist;