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 &);
177 void readAlign(LyXLex &);
178 void readAlignPossible(LyXLex &);
179 void readLabelType(LyXLex &);
180 void readMargin(LyXLex &);
181 void readLatexType(LyXLex &);
182 void readSpacing(LyXLex &);
183 string const & name() const { return name_; }
184 void name(string const & n) { name_ = n; }
185 string const & obsoleted_by() const { return obsoleted_by_; }
186 string const & latexname() const { return latexname_; }
187 string const & labelstring() const { return labelstring_; }
188 string const & preamble() const { return preamble_; }
189 string const & latexparam() const { return latexparam_; }
190 string const & labelstring_appendix() const { return labelstring_appendix_; }
191 /** Default font for this layout/environment.
192 The main font for this kind of environment. If an attribute has
193 LyXFont::INHERITED_*, it means that the value is specified by
194 the defaultfont for the entire layout. If we are nested, the
195 font is inherited from the font in the environment one level
196 up until the font is resolved. The values LyXFont::IGNORE_*
197 and LyXFont::TOGGLE are illegal here.
201 /** Default font for labels.
202 Interpretation the same as for font above
206 /** Resolved version of the font for this layout/environment.
207 This is a resolved version the default font. The font is resolved
208 against the defaultfont of the entire layout.
212 /** Resolved version of the font used for labels.
213 This is a resolved version the label font. The font is resolved
214 against the defaultfont of the entire layout.
216 LyXFont reslabelfont;
218 /// Text that dictates how wide the left margin is on the screen
221 /// Text that dictates how wide the right margin is on the screen
224 /// Text that dictates how much space to leave after a potential label
227 /// Text that dictates how much space to leave before a potential label
230 /** Text that dictates the width of the indentation of
248 float labelbottomsep;
257 LyXAlignment align; // add approp. signedness
260 LyXAlignment alignpossible; // add approp. signedness
263 char labeltype; // add approp. signedness
266 char margintype; // add approp. signedness
275 bool newline_allowed;
282 /// true when the fragile commands in the paragraph need to be
285 /// true when empty paragraphs should be kept.
288 bool isParagraph() const {
289 return latextype == LATEX_PARAGRAPH;
292 bool isCommand() const {
293 return latextype == LATEX_COMMAND;
296 bool isEnvironment() const {
297 return (latextype == LATEX_ENVIRONMENT
298 || latextype == LATEX_ITEM_ENVIRONMENT
299 || latextype == LATEX_LIST_ENVIRONMENT);
301 /// Type of LaTeX object
302 LYX_LATEX_TYPES latextype;
303 /// Does this object belong in the title part of the document?
306 /// Name of the layout/paragraph environment
309 /** Name of an layout that has replaced this layout.
310 This is used to rename a layout, while keeping backward
313 string obsoleted_by_;
315 /// LaTeX name for environment
318 /// Label string. "Abstract", "Reference", "Caption"...
321 /// Label string inside appendix. "Appendix", ...
322 string labelstring_appendix_;
324 /// LaTeX parameter for environment
327 /// Macro definitions needed for this layout
336 typedef vector<LyXLayout> LayoutList;
339 LyXTextClass (string const & = string(),
340 string const & = string(),
341 string const & = string());
344 LayoutList::const_iterator begin() const { return layoutlist.begin(); }
346 LayoutList::const_iterator end() const { return layoutlist.end(); }
349 bool Read(string const & filename, bool merge = false);
350 void readOutputType(LyXLex &);
351 void readMaxCounter(LyXLex &);
352 void readClassOptions(LyXLex &);
354 bool hasLayout(string const & name) const;
357 LyXLayout const & GetLayout(string const & vname) const;
360 LyXLayout & GetLayout(string const & vname);
362 /// Sees to that the textclass structure has been loaded
366 string const & name() const { return name_; }
368 string const & latexname() const { return latexname_; }
370 string const & description() const { return description_; }
372 string const & opt_fontsize() const { return opt_fontsize_; }
374 string const & opt_pagestyle() const { return opt_pagestyle_; }
376 string const & options() const { return options_; }
378 string const & pagestyle() const { return pagestyle_; }
380 string const & preamble() const { return preamble_; }
382 /// Packages that are already loaded by the class
389 bool provides(Provides p) const { return provides_ & p; }
392 unsigned int columns() const { return columns_; }
399 PageSides sides() const { return sides_; }
401 int secnumdepth() const { return secnumdepth_; }
403 int tocdepth() const { return tocdepth_; }
406 OutputType outputType() const { return outputType_; }
409 LyXFont const & defaultfont() const { return defaultfont_; }
411 /// Text that dictates how wide the left margin is on the screen
412 string const & leftmargin() const { return leftmargin_; }
414 /// Text that dictates how wide the right margin is on the screen
415 string const & rightmargin() const { return rightmargin_; }
417 int maxcounter() const { return maxcounter_; }
419 LayoutList::size_type numLayouts() const { return layoutlist.size(); }
421 LyXLayout const & operator[](LayoutList::size_type i) const {
422 return layoutlist[i];
426 bool delete_layout(string const &);
428 bool do_readStyle(LyXLex &, LyXLayout &);
435 /// Specific class options
436 string opt_fontsize_;
438 string opt_pagestyle_;
448 unsigned int columns_;
456 OutputType outputType_;
457 /** Base font. The paragraph and layout fonts are resolved against
458 this font. This has to be fully instantiated. Attributes
459 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
462 LyXFont defaultfont_;
463 /// Text that dictates how wide the left margin is on the screen
466 /// Text that dictates how wide the right margin is on the screen
469 int maxcounter_; // add approp. signedness
472 LayoutList layoutlist;
474 /// Has this layout file been loaded yet?
479 inline void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
481 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
485 inline ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
488 case LyXTextClass::OneSide:
491 case LyXTextClass::TwoSides:
499 class LyXTextClassList {
502 typedef vector<LyXTextClass> ClassList;
503 /// Gets layout structure from layout number and textclass number
504 LyXLayout const & Style(ClassList::size_type textclass,
505 LyXTextClass::LayoutList::size_type layout) const;
507 /// Gets layout number from textclass number and layout name
508 pair<bool, LyXTextClass::LayoutList::size_type>
509 NumberOfLayout(ClassList::size_type textclass,
510 string const & name) const;
512 /// Gets a layout name from layout number and textclass number
514 NameOfLayout(ClassList::size_type textclass,
515 LyXTextClass::LayoutList::size_type layout) const;
517 /** Gets textclass number from name.
518 Returns -1 if textclass name does not exist
520 pair<bool, ClassList::size_type>
521 NumberOfClass(string const & textclass) const;
524 string const & NameOfClass(ClassList::size_type number) const;
527 string const & LatexnameOfClass(ClassList::size_type number) const;
530 string const & DescOfClass(ClassList::size_type number) const;
533 LyXTextClass const & TextClass(ClassList::size_type textclass) const;
535 /** Read textclass list.
536 Returns false if this fails
541 Returns false if this fails
543 bool Load(ClassList::size_type number) const;
546 mutable ClassList classlist;
548 void Add (LyXTextClass const &);
551 /// Should not be declared here!! (Lgb) Why not? (Asger)
552 extern LyXTextClassList textclasslist;