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 * ====================================================== */
25 /// Reads the style files
26 extern void LyXSetStyle();
29 enum { // no good name for this
31 LYX_ENVIRONMENT_DEFAULT = 97,
33 LYX_LAYOUT_DEFAULT = 99
35 // Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has
36 // the same value? (Lgb)
38 #define LYX_DUMMY_LAYOUT 99
40 /// The different output types
52 /// The different margin types
53 enum LYX_MARGIN_TYPE {
63 MARGIN_RIGHT_ADDRESS_BOX
80 LYX_ALIGN_LAYOUT = 16,
82 LYX_ALIGN_SPECIAL = 32
87 void operator|=(LyXAlignment & la1, LyXAlignment la2) {
88 la1 = static_cast<LyXAlignment>(la1 | la2);
91 /// The different LaTeX-Types
92 enum LYX_LATEX_TYPES {
100 LATEX_ITEM_ENVIRONMENT,
102 LATEX_LIST_ENVIRONMENT
105 /// The different label types
106 enum LYX_LABEL_TYPES {
114 LABEL_TOP_ENVIRONMENT,
116 LABEL_CENTERED_TOP_ENVIRONMENT,
118 // the flushright labels following now must start with LABEL_STATIC
124 LABEL_COUNTER_CHAPTER,
126 LABEL_COUNTER_SECTION,
128 LABEL_COUNTER_SUBSECTION,
130 LABEL_COUNTER_SUBSUBSECTION,
132 LABEL_COUNTER_PARAGRAPH,
134 LABEL_COUNTER_SUBPARAGRAPH,
138 LABEL_COUNTER_ENUMII,
140 LABEL_COUNTER_ENUMIII,
142 LABEL_COUNTER_ENUMIV,
144 LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
147 enum LYX_END_LABEL_TYPES {
153 END_LABEL_FILLED_BOX,
155 END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
157 END_LABEL_ENUM_LAST = END_LABEL_FILLED_BOX
160 /* Fix labels are printed flushright, manual labels flushleft.
161 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
162 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
163 * This seems a funny restriction, but I think other combinations are
164 * not needed, so I will not change it yet.
165 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
169 /* There is a parindent and a parskip. Which one is used depends on the
170 * paragraph_separation-flag of the text-object.
171 * BUT: parindent is only thrown away, if a parskip is defined! So if you
172 * want a space between the paragraphs and a parindent at the same time,
173 * you should set parskip to zero and use topsep, parsep and bottomsep.
175 * The standard layout is an exception: its parindent is only set, if the
176 * previous paragraph is standard too. Well, this is LateX and it is good!
180 /// Attributes of a layout/paragraph environment
190 bool Read (LyXLex &, LyXTextClass const &);
191 void readAlign(LyXLex &);
192 void readAlignPossible(LyXLex &);
193 void readLabelType(LyXLex &);
194 void readEndLabelType(LyXLex &);
195 void readMargin(LyXLex &);
196 void readLatexType(LyXLex &);
197 void readSpacing(LyXLex &);
198 string const & name() const { return name_; }
199 void name(string const & n) { name_ = n; }
200 string const & obsoleted_by() const { return obsoleted_by_; }
201 string const & latexname() const { return latexname_; }
202 string const & labelstring() const { return labelstring_; }
203 string const & preamble() const { return preamble_; }
204 string const & latexparam() const { return latexparam_; }
205 string const & labelstring_appendix() const {
206 return labelstring_appendix_;
208 /** Default font for this layout/environment.
209 The main font for this kind of environment. If an attribute has
210 LyXFont::INHERITED_*, it means that the value is specified by
211 the defaultfont for the entire layout. If we are nested, the
212 font is inherited from the font in the environment one level
213 up until the font is resolved. The values LyXFont::IGNORE_*
214 and LyXFont::TOGGLE are illegal here.
218 /** Default font for labels.
219 Interpretation the same as for font above
223 /** Resolved version of the font for this layout/environment.
224 This is a resolved version the default font. The font is resolved
225 against the defaultfont of the entire layout.
229 /** Resolved version of the font used for labels.
230 This is a resolved version the label font. The font is resolved
231 against the defaultfont of the entire layout.
233 LyXFont reslabelfont;
235 /// Text that dictates how wide the left margin is on the screen
238 /// Text that dictates how wide the right margin is on the screen
241 /// Text that dictates how much space to leave after a potential label
244 /// Text that dictates how much space to leave before a potential label
247 /** Text that dictates the width of the indentation of
265 float labelbottomsep;
277 LyXAlignment alignpossible;
280 char labeltype; // add approp. type
286 LYX_MARGIN_TYPE margintype;
295 bool newline_allowed;
302 /// true when the fragile commands in the paragraph need to be
305 /// true when empty paragraphs should be kept.
308 bool isParagraph() const {
309 return latextype == LATEX_PARAGRAPH;
312 bool isCommand() const {
313 return latextype == LATEX_COMMAND;
316 bool isEnvironment() const {
317 return (latextype == LATEX_ENVIRONMENT
318 || latextype == LATEX_ITEM_ENVIRONMENT
319 || latextype == LATEX_LIST_ENVIRONMENT);
321 /// Type of LaTeX object
322 LYX_LATEX_TYPES latextype;
323 /// Does this object belong in the title part of the document?
326 /// Name of the layout/paragraph environment
329 /** Name of an layout that has replaced this layout.
330 This is used to rename a layout, while keeping backward
333 string obsoleted_by_;
335 /// LaTeX name for environment
338 /// Label string. "Abstract", "Reference", "Caption"...
341 /// Label string inside appendix. "Appendix", ...
342 string labelstring_appendix_;
344 /// LaTeX parameter for environment
347 /// Macro definitions needed for this layout
356 typedef std::vector<LyXLayout> LayoutList;
358 typedef LayoutList::const_iterator const_iterator;
360 typedef LayoutList::size_type size_type;
362 LyXTextClass (string const & = string(),
363 string const & = string(),
364 string const & = string());
367 const_iterator begin() const { return layoutlist.begin(); }
369 const_iterator end() const { return layoutlist.end(); }
372 bool Read(string const & filename, bool merge = false);
373 void readOutputType(LyXLex &);
374 void readMaxCounter(LyXLex &);
375 void readClassOptions(LyXLex &);
377 bool hasLayout(string const & name) const;
380 LyXLayout const & GetLayout(string const & vname) const;
383 LyXLayout & GetLayout(string const & vname);
385 /// Sees to that the textclass structure has been loaded
389 string const & name() const { return name_; }
391 string const & latexname() const { return latexname_; }
393 string const & description() const { return description_; }
395 string const & opt_fontsize() const { return opt_fontsize_; }
397 string const & opt_pagestyle() const { return opt_pagestyle_; }
399 string const & options() const { return options_; }
401 string const & pagestyle() const { return pagestyle_; }
403 string const & preamble() const { return preamble_; }
405 /// Packages that are already loaded by the class
412 bool provides(Provides p) const { return provides_ & p; }
415 unsigned int columns() const { return columns_; }
422 PageSides sides() const { return sides_; }
424 int secnumdepth() const { return secnumdepth_; }
426 int tocdepth() const { return tocdepth_; }
429 OutputType outputType() const { return outputType_; }
432 LyXFont const & defaultfont() const { return defaultfont_; }
434 /// Text that dictates how wide the left margin is on the screen
435 string const & leftmargin() const { return leftmargin_; }
437 /// Text that dictates how wide the right margin is on the screen
438 string const & rightmargin() const { return rightmargin_; }
440 int maxcounter() const { return maxcounter_; }
442 size_type numLayouts() const { return layoutlist.size(); }
444 LyXLayout const & operator[](size_type i) const {
445 return layoutlist[i];
449 bool delete_layout(string const &);
451 bool do_readStyle(LyXLex &, LyXLayout &);
458 /// Specific class options
459 string opt_fontsize_;
461 string opt_pagestyle_;
471 unsigned int columns_;
479 OutputType outputType_;
480 /** Base font. The paragraph and layout fonts are resolved against
481 this font. This has to be fully instantiated. Attributes
482 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
485 LyXFont defaultfont_;
486 /// Text that dictates how wide the left margin is on the screen
489 /// Text that dictates how wide the right margin is on the screen
492 int maxcounter_; // add approp. signedness
495 LayoutList layoutlist;
497 /// Has this layout file been loaded yet?
504 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
506 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
512 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p)
515 case LyXTextClass::OneSide:
518 case LyXTextClass::TwoSides:
527 class LyXTextClassList {
530 typedef std::vector<LyXTextClass> ClassList;
532 typedef ClassList::const_iterator const_iterator;
534 typedef ClassList::size_type size_type;
536 const_iterator begin() const { return classlist.begin(); }
538 const_iterator end() const { return classlist.end(); }
540 /// Gets layout structure from layout number and textclass number
541 LyXLayout const & Style(size_type textclass,
542 LyXTextClass::size_type layout) const;
544 /// Gets layout number from textclass number and layout name
545 std::pair<bool, LyXTextClass::size_type>
546 NumberOfLayout(size_type textclass,
547 string const & name) const;
549 /// Gets a layout name from layout number and textclass number
551 NameOfLayout(size_type textclass,
552 LyXTextClass::size_type layout) const;
554 /** Gets textclass number from name.
555 Returns -1 if textclass name does not exist
557 std::pair<bool, size_type>
558 NumberOfClass(string const & textclass) const;
561 string const & NameOfClass(size_type number) const;
564 string const & LatexnameOfClass(size_type number) const;
567 string const & DescOfClass(size_type number) const;
570 LyXTextClass const & TextClass(size_type textclass) const;
572 /** Read textclass list.
573 Returns false if this fails
578 Returns false if this fails
580 bool Load(size_type number) const;
583 mutable ClassList classlist;
585 void Add (LyXTextClass const &);
588 /// Should not be declared here!! (Lgb) Why not? (Asger)
589 extern LyXTextClassList textclasslist;