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
82 LYX_ALIGN_LAYOUT = 16,
84 LYX_ALIGN_SPECIAL = 32
88 inline 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
149 /* Fix labels are printed flushright, manual labels flushleft.
150 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
151 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
152 * This seems a funny restriction, but I think other combinations are
153 * not needed, so I will not change it yet.
154 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
158 /* There is a parindent and a parskip. Which one is used depends on the
159 * paragraph_separation-flag of the text-object.
160 * BUT: parindent is only thrown away, if a parskip is defined! So if you
161 * want a space between the paragraphs and a parindent at the same time,
162 * you should set parskip to zero and use topsep, parsep and bottomsep.
164 * The standard layout is an exception: its parindent is only set, if the
165 * previous paragraph is standard too. Well, this is LateX and it is good!
169 /// Attributes of a layout/paragraph environment
179 bool Read (LyXLex &, LyXTextClass const &);
180 void readAlign(LyXLex &);
181 void readAlignPossible(LyXLex &);
182 void readLabelType(LyXLex &);
183 void readMargin(LyXLex &);
184 void readLatexType(LyXLex &);
185 void readSpacing(LyXLex &);
186 string const & name() const { return name_; }
187 void name(string const & n) { name_ = n; }
188 string const & obsoleted_by() const { return obsoleted_by_; }
189 string const & latexname() const { return latexname_; }
190 string const & labelstring() const { return labelstring_; }
191 string const & preamble() const { return preamble_; }
192 string const & latexparam() const { return latexparam_; }
193 string const & labelstring_appendix() const {
194 return labelstring_appendix_;
196 /** Default font for this layout/environment.
197 The main font for this kind of environment. If an attribute has
198 LyXFont::INHERITED_*, it means that the value is specified by
199 the defaultfont for the entire layout. If we are nested, the
200 font is inherited from the font in the environment one level
201 up until the font is resolved. The values LyXFont::IGNORE_*
202 and LyXFont::TOGGLE are illegal here.
206 /** Default font for labels.
207 Interpretation the same as for font above
211 /** Resolved version of the font for this layout/environment.
212 This is a resolved version the default font. The font is resolved
213 against the defaultfont of the entire layout.
217 /** Resolved version of the font used for labels.
218 This is a resolved version the label font. The font is resolved
219 against the defaultfont of the entire layout.
221 LyXFont reslabelfont;
223 /// Text that dictates how wide the left margin is on the screen
226 /// Text that dictates how wide the right margin is on the screen
229 /// Text that dictates how much space to leave after a potential label
232 /// Text that dictates how much space to leave before a potential label
235 /** Text that dictates the width of the indentation of
253 float labelbottomsep;
265 LyXAlignment alignpossible;
268 char labeltype; // add approp. type
271 char margintype; // add approp. type
280 bool newline_allowed;
287 /// true when the fragile commands in the paragraph need to be
290 /// true when empty paragraphs should be kept.
293 bool isParagraph() const {
294 return latextype == LATEX_PARAGRAPH;
297 bool isCommand() const {
298 return latextype == LATEX_COMMAND;
301 bool isEnvironment() const {
302 return (latextype == LATEX_ENVIRONMENT
303 || latextype == LATEX_ITEM_ENVIRONMENT
304 || latextype == LATEX_LIST_ENVIRONMENT);
306 /// Type of LaTeX object
307 LYX_LATEX_TYPES latextype;
308 /// Does this object belong in the title part of the document?
311 /// Name of the layout/paragraph environment
314 /** Name of an layout that has replaced this layout.
315 This is used to rename a layout, while keeping backward
318 string obsoleted_by_;
320 /// LaTeX name for environment
323 /// Label string. "Abstract", "Reference", "Caption"...
326 /// Label string inside appendix. "Appendix", ...
327 string labelstring_appendix_;
329 /// LaTeX parameter for environment
332 /// Macro definitions needed for this layout
341 typedef vector<LyXLayout> LayoutList;
343 typedef LayoutList::const_iterator const_iterator;
345 typedef LayoutList::size_type size_type;
347 LyXTextClass (string const & = string(),
348 string const & = string(),
349 string const & = string());
352 const_iterator begin() const { return layoutlist.begin(); }
354 const_iterator end() const { return layoutlist.end(); }
357 bool Read(string const & filename, bool merge = false);
358 void readOutputType(LyXLex &);
359 void readMaxCounter(LyXLex &);
360 void readClassOptions(LyXLex &);
362 bool hasLayout(string const & name) const;
365 LyXLayout const & GetLayout(string const & vname) const;
368 LyXLayout & GetLayout(string const & vname);
370 /// Sees to that the textclass structure has been loaded
374 string const & name() const { return name_; }
376 string const & latexname() const { return latexname_; }
378 string const & description() const { return description_; }
380 string const & opt_fontsize() const { return opt_fontsize_; }
382 string const & opt_pagestyle() const { return opt_pagestyle_; }
384 string const & options() const { return options_; }
386 string const & pagestyle() const { return pagestyle_; }
388 string const & preamble() const { return preamble_; }
390 /// Packages that are already loaded by the class
397 bool provides(Provides p) const { return provides_ & p; }
400 unsigned int columns() const { return columns_; }
407 PageSides sides() const { return sides_; }
409 int secnumdepth() const { return secnumdepth_; }
411 int tocdepth() const { return tocdepth_; }
414 OutputType outputType() const { return outputType_; }
417 LyXFont const & defaultfont() const { return defaultfont_; }
419 /// Text that dictates how wide the left margin is on the screen
420 string const & leftmargin() const { return leftmargin_; }
422 /// Text that dictates how wide the right margin is on the screen
423 string const & rightmargin() const { return rightmargin_; }
425 int maxcounter() const { return maxcounter_; }
427 size_type numLayouts() const { return layoutlist.size(); }
429 LyXLayout const & operator[](size_type i) const {
430 return layoutlist[i];
434 bool delete_layout(string const &);
436 bool do_readStyle(LyXLex &, LyXLayout &);
443 /// Specific class options
444 string opt_fontsize_;
446 string opt_pagestyle_;
456 unsigned int columns_;
464 OutputType outputType_;
465 /** Base font. The paragraph and layout fonts are resolved against
466 this font. This has to be fully instantiated. Attributes
467 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
470 LyXFont defaultfont_;
471 /// Text that dictates how wide the left margin is on the screen
474 /// Text that dictates how wide the right margin is on the screen
477 int maxcounter_; // add approp. signedness
480 LayoutList layoutlist;
482 /// Has this layout file been loaded yet?
488 inline void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
490 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
495 inline ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
498 case LyXTextClass::OneSide:
501 case LyXTextClass::TwoSides:
510 class LyXTextClassList {
513 typedef vector<LyXTextClass> ClassList;
515 typedef ClassList::const_iterator const_iterator;
517 typedef ClassList::size_type size_type;
519 const_iterator begin() const { return classlist.begin(); }
521 const_iterator end() const { return classlist.end(); }
523 /// Gets layout structure from layout number and textclass number
524 LyXLayout const & Style(size_type textclass,
525 LyXTextClass::size_type layout) const;
527 /// Gets layout number from textclass number and layout name
528 pair<bool, LyXTextClass::size_type>
529 NumberOfLayout(size_type textclass,
530 string const & name) const;
532 /// Gets a layout name from layout number and textclass number
534 NameOfLayout(size_type textclass,
535 LyXTextClass::size_type layout) const;
537 /** Gets textclass number from name.
538 Returns -1 if textclass name does not exist
540 pair<bool, size_type>
541 NumberOfClass(string const & textclass) const;
544 string const & NameOfClass(size_type number) const;
547 string const & LatexnameOfClass(size_type number) const;
550 string const & DescOfClass(size_type number) const;
553 LyXTextClass const & TextClass(size_type textclass) const;
555 /** Read textclass list.
556 Returns false if this fails
561 Returns false if this fails
563 bool Load(size_type number) const;
566 mutable ClassList classlist;
568 void Add (LyXTextClass const &);
571 /// Should not be declared here!! (Lgb) Why not? (Asger)
572 extern LyXTextClassList textclasslist;