2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 The LyX Team.
10 * ====================================================== */
27 /// Reads the style files
28 extern void LyXSetStyle();
31 enum { // no good name for this
33 LYX_ENVIRONMENT_DEFAULT = 97,
35 LYX_LAYOUT_DEFAULT = 99
37 // Could this cause confusion that both DUMMY_LAYOUT and LAYOUT_DEFAULT has
38 // the same value? (Lgb)
40 #define LYX_DUMMY_LAYOUT 99
42 /// The different output types
54 /// The different margin types
55 enum LYX_MARGIN_TYPE {
65 MARGIN_RIGHT_ADDRESS_BOX
81 LYX_ALIGN_LAYOUT = 16,
83 LYX_ALIGN_SPECIAL = 32
85 inline void operator|=(LyXAlignment & la1, LyXAlignment la2) {
86 la1 = static_cast<LyXAlignment>(la1 | la2);
89 /// The different LaTeX-Types
90 enum LYX_LATEX_TYPES {
98 LATEX_ITEM_ENVIRONMENT,
100 LATEX_LIST_ENVIRONMENT
103 /// The different label types
104 enum LYX_LABEL_TYPES {
112 LABEL_TOP_ENVIRONMENT,
114 LABEL_CENTERED_TOP_ENVIRONMENT,
116 // the flushright labels following now must start with LABEL_STATIC
122 LABEL_COUNTER_CHAPTER,
124 LABEL_COUNTER_SECTION,
126 LABEL_COUNTER_SUBSECTION,
128 LABEL_COUNTER_SUBSUBSECTION,
130 LABEL_COUNTER_PARAGRAPH,
132 LABEL_COUNTER_SUBPARAGRAPH,
136 LABEL_COUNTER_ENUMII,
138 LABEL_COUNTER_ENUMIII,
140 LABEL_COUNTER_ENUMIV,
142 LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
146 /* Fix labels are printed flushright, manual labels flushleft.
147 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
148 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
149 * This seems a funny restriction, but I think other combinations are
150 * not needed, so I will not change it yet.
151 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
155 /* There is a parindent and a parskip. Which one is used depends on the
156 * paragraph_separation-flag of the text-object.
157 * BUT: parindent is only thrown away, if a parskip is defined! So if you
158 * want a space between the paragraphs and a parindent at the same time,
159 * you should set parskip to zero and use topsep, parsep and bottomsep.
161 * The standard layout is an exception: its parindent is only set, if the
162 * previous paragraph is standard too. Well, this is LateX and it is good!
166 /// Attributes of a layout/paragraph environment
176 bool Read (LyXLex &, LyXTextClass const &);
178 string const & name() const { return name_; }
179 void name(string const & n) { name_ = n; }
180 string const & obsoleted_by() const { return obsoleted_by_; }
181 string const & latexname() const { return latexname_; }
182 string const & labelstring() const { return labelstring_; }
183 string const & preamble() const { return preamble_; }
184 string const & latexparam() const { return latexparam_; }
185 string const & labelstring_appendix() const { return labelstring_appendix_; }
186 /** Default font for this layout/environment.
187 The main font for this kind of environment. If an attribute has
188 LyXFont::INHERITED_*, it means that the value is specified by
189 the defaultfont for the entire layout. If we are nested, the
190 font is inherited from the font in the environment one level
191 up until the font is resolved. The values LyXFont::IGNORE_*
192 and LyXFont::TOGGLE are illegal here.
196 /** Default font for labels.
197 Interpretation the same as for font above
201 /** Resolved version of the font for this layout/environment.
202 This is a resolved version the default font. The font is resolved
203 against the defaultfont of the entire layout.
207 /** Resolved version of the font used for labels.
208 This is a resolved version the label font. The font is resolved
209 against the defaultfont of the entire layout.
211 LyXFont reslabelfont;
213 /// Text that dictates how wide the left margin is on the screen
216 /// Text that dictates how wide the right margin is on the screen
219 /// Text that dictates how much space to leave after a potential label
222 /// Text that dictates how much space to leave before a potential label
225 /** Text that dictates the width of the indentation of
243 float labelbottomsep;
252 LyXAlignment align; // add approp. signedness
255 LyXAlignment alignpossible; // add approp. signedness
258 char labeltype; // add approp. signedness
261 char margintype; // add approp. signedness
270 bool newline_allowed;
277 /// true when the fragile commands in the paragraph need to be
280 /// true when empty paragraphs should be kept.
283 bool isParagraph() const {
284 return latextype == LATEX_PARAGRAPH;
287 bool isCommand() const {
288 return latextype == LATEX_COMMAND;
291 bool isEnvironment() const {
292 return (latextype == LATEX_ENVIRONMENT
293 || latextype == LATEX_ITEM_ENVIRONMENT
294 || latextype == LATEX_LIST_ENVIRONMENT);
296 /// Type of LaTeX object
297 LYX_LATEX_TYPES latextype;
298 /// Does this object belong in the title part of the document?
301 /// Name of the layout/paragraph environment
304 /** Name of an layout that has replaced this layout.
305 This is used to rename a layout, while keeping backward
308 string obsoleted_by_;
310 /// LaTeX name for environment
313 /// Label string. "Abstract", "Reference", "Caption"...
316 /// Label string inside appendix. "Appendix", ...
317 string labelstring_appendix_;
319 /// LaTeX parameter for environment
322 /// Macro definitions needed for this layout
331 typedef vector<LyXLayout> LayoutList;
334 LyXTextClass (string const & = string(),
335 string const & = string(),
336 string const & = string());
339 LayoutList::const_iterator begin() const { return layoutlist.begin(); }
341 LayoutList::const_iterator end() const { return layoutlist.end(); }
344 bool Read(string const & filename, bool merge = false);
347 bool hasLayout(string const & name) const;
350 LyXLayout const & GetLayout(string const & vname) const;
353 LyXLayout & GetLayout(string const & vname);
355 /// Sees to that the textclass structure has been loaded
359 string const & name() const { return name_; }
361 string const & latexname() const { return latexname_; }
363 string const & description() const { return description_; }
365 string const & opt_fontsize() const { return opt_fontsize_; }
367 string const & opt_pagestyle() const { return opt_pagestyle_; }
369 string const & options() const { return options_; }
371 string const & pagestyle() const { return pagestyle_; }
373 string const & preamble() const { return preamble_; }
375 /// Packages that are already loaded by the class
382 bool provides(Provides p) const { return provides_ & p; }
385 unsigned int columns() const { return columns_; }
392 PageSides sides() const { return sides_; }
394 int secnumdepth() const { return secnumdepth_; }
396 int tocdepth() const { return tocdepth_; }
399 OutputType outputType() const { return outputType_; }
402 LyXFont const & defaultfont() const { return defaultfont_; }
404 /// Text that dictates how wide the left margin is on the screen
405 string const & leftmargin() const { return leftmargin_; }
407 /// Text that dictates how wide the right margin is on the screen
408 string const & rightmargin() const { return rightmargin_; }
410 int maxcounter() const { return maxcounter_; }
412 LayoutList::size_type numLayouts() const { return layoutlist.size(); }
414 LyXLayout const & operator[](LayoutList::size_type i) const {
415 return layoutlist[i];
419 bool delete_layout(string const &);
421 bool do_readStyle(LyXLex &, LyXLayout &);
428 /// Specific class options
429 string opt_fontsize_;
431 string opt_pagestyle_;
441 unsigned int columns_;
449 OutputType outputType_;
450 /** Base font. The paragraph and layout fonts are resolved against
451 this font. This has to be fully instantiated. Attributes
452 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
455 LyXFont defaultfont_;
456 /// Text that dictates how wide the left margin is on the screen
459 /// Text that dictates how wide the right margin is on the screen
462 int maxcounter_; // add approp. signedness
465 LayoutList layoutlist;
467 /// Has this layout file been loaded yet?
472 inline void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
474 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
479 class LyXTextClassList {
482 typedef vector<LyXTextClass> ClassList;
483 /// Gets layout structure from layout number and textclass number
484 LyXLayout const & Style(ClassList::size_type textclass,
485 LyXTextClass::LayoutList::size_type layout) const;
487 /// Gets layout number from textclass number and layout name
488 pair<bool, LyXTextClass::LayoutList::size_type>
489 NumberOfLayout(ClassList::size_type textclass,
490 string const & name) const;
492 /// Gets a layout name from layout number and textclass number
494 NameOfLayout(ClassList::size_type textclass,
495 LyXTextClass::LayoutList::size_type layout) const;
497 /** Gets textclass number from name.
498 Returns -1 if textclass name does not exist
500 pair<bool, ClassList::size_type>
501 NumberOfClass(string const & textclass) const;
504 string const & NameOfClass(ClassList::size_type number) const;
507 string const & LatexnameOfClass(ClassList::size_type number) const;
510 string const & DescOfClass(ClassList::size_type number) const;
513 LyXTextClass const & TextClass(ClassList::size_type textclass) const;
515 /** Read textclass list.
516 Returns false if this fails
521 Returns false if this fails
523 bool Load(ClassList::size_type number) const;
526 mutable ClassList classlist;
528 void Add (LyXTextClass const &);
531 /// Should not be declared here!! (Lgb) Why not? (Asger)
532 extern LyXTextClassList textclasslist;