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,
156 END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
158 END_LABEL_ENUM_LAST = END_LABEL_FILLED_BOX
161 /* Fix labels are printed flushright, manual labels flushleft.
162 * MARGIN_MANUAL and MARGIN_FIRST_DYNAMIC are *only* for LABEL_MANUAL,
163 * MARGIN_DYNAMIC and MARGIN_STATIC are *not* for LABEL_MANUAL.
164 * This seems a funny restriction, but I think other combinations are
165 * not needed, so I will not change it yet.
166 * Correction: MARGIN_FIRST_DYNAMIC also usable with LABEL_STATIC
170 /* There is a parindent and a parskip. Which one is used depends on the
171 * paragraph_separation-flag of the text-object.
172 * BUT: parindent is only thrown away, if a parskip is defined! So if you
173 * want a space between the paragraphs and a parindent at the same time,
174 * you should set parskip to zero and use topsep, parsep and bottomsep.
176 * The standard layout is an exception: its parindent is only set, if the
177 * previous paragraph is standard too. Well, this is LateX and it is good!
181 /// Attributes of a layout/paragraph environment
191 bool Read (LyXLex &, LyXTextClass const &);
192 void readAlign(LyXLex &);
193 void readAlignPossible(LyXLex &);
194 void readLabelType(LyXLex &);
195 void readEndLabelType(LyXLex &);
196 void readMargin(LyXLex &);
197 void readLatexType(LyXLex &);
198 void readSpacing(LyXLex &);
199 string const & name() const { return name_; }
200 void name(string const & n) { name_ = n; }
201 string const & obsoleted_by() const { return obsoleted_by_; }
202 string const & latexname() const { return latexname_; }
203 string const & labelstring() const { return labelstring_; }
204 string const & preamble() const { return preamble_; }
205 string const & latexparam() const { return latexparam_; }
206 string const & labelstring_appendix() const {
207 return labelstring_appendix_;
209 /** Default font for this layout/environment.
210 The main font for this kind of environment. If an attribute has
211 LyXFont::INHERITED_*, it means that the value is specified by
212 the defaultfont for the entire layout. If we are nested, the
213 font is inherited from the font in the environment one level
214 up until the font is resolved. The values LyXFont::IGNORE_*
215 and LyXFont::TOGGLE are illegal here.
219 /** Default font for labels.
220 Interpretation the same as for font above
224 /** Resolved version of the font for this layout/environment.
225 This is a resolved version the default font. The font is resolved
226 against the defaultfont of the entire layout.
230 /** Resolved version of the font used for labels.
231 This is a resolved version the label font. The font is resolved
232 against the defaultfont of the entire layout.
234 LyXFont reslabelfont;
236 /// Text that dictates how wide the left margin is on the screen
239 /// Text that dictates how wide the right margin is on the screen
242 /// Text that dictates how much space to leave after a potential label
245 /// Text that dictates how much space to leave before a potential label
248 /** Text that dictates the width of the indentation of
266 float labelbottomsep;
278 LyXAlignment alignpossible;
281 char labeltype; // add approp. type
287 LYX_MARGIN_TYPE margintype;
296 bool newline_allowed;
303 /// true when the fragile commands in the paragraph need to be
306 /// true when empty paragraphs should be kept.
309 bool isParagraph() const {
310 return latextype == LATEX_PARAGRAPH;
313 bool isCommand() const {
314 return latextype == LATEX_COMMAND;
317 bool isEnvironment() const {
318 return (latextype == LATEX_ENVIRONMENT
319 || latextype == LATEX_ITEM_ENVIRONMENT
320 || latextype == LATEX_LIST_ENVIRONMENT);
322 /// Type of LaTeX object
323 LYX_LATEX_TYPES latextype;
324 /// Does this object belong in the title part of the document?
327 /// Name of the layout/paragraph environment
330 /** Name of an layout that has replaced this layout.
331 This is used to rename a layout, while keeping backward
334 string obsoleted_by_;
336 /// LaTeX name for environment
339 /// Label string. "Abstract", "Reference", "Caption"...
342 /// Label string inside appendix. "Appendix", ...
343 string labelstring_appendix_;
345 /// LaTeX parameter for environment
348 /// Macro definitions needed for this layout
357 typedef std::vector<LyXLayout> LayoutList;
359 typedef LayoutList::const_iterator const_iterator;
361 typedef LayoutList::size_type size_type;
364 LyXTextClass (string const & = string(),
365 string const & = string(),
366 string const & = string());
369 const_iterator begin() const { return layoutlist.begin(); }
371 const_iterator end() const { return layoutlist.end(); }
374 bool Read(string const & filename, bool merge = false);
375 void readOutputType(LyXLex &);
376 void readMaxCounter(LyXLex &);
377 void readClassOptions(LyXLex &);
379 bool hasLayout(string const & name) const;
382 LyXLayout const & GetLayout(string const & vname) const;
385 LyXLayout & GetLayout(string const & vname);
387 /// Sees to that the textclass structure has been loaded
391 string const & name() const { return name_; }
393 string const & latexname() const { return latexname_; }
395 string const & description() const { return description_; }
397 string const & opt_fontsize() const { return opt_fontsize_; }
399 string const & opt_pagestyle() const { return opt_pagestyle_; }
401 string const & options() const { return options_; }
403 string const & pagestyle() const { return pagestyle_; }
405 string const & preamble() const { return preamble_; }
407 /// Packages that are already loaded by the class
414 bool provides(Provides p) const { return provides_ & p; }
417 unsigned int columns() const { return columns_; }
424 PageSides sides() const { return sides_; }
426 int secnumdepth() const { return secnumdepth_; }
428 int tocdepth() const { return tocdepth_; }
431 OutputType outputType() const { return outputType_; }
434 LyXFont const & defaultfont() const { return defaultfont_; }
436 /// Text that dictates how wide the left margin is on the screen
437 string const & leftmargin() const { return leftmargin_; }
439 /// Text that dictates how wide the right margin is on the screen
440 string const & rightmargin() const { return rightmargin_; }
442 int maxcounter() const { return maxcounter_; }
444 size_type numLayouts() const { return layoutlist.size(); }
446 LyXLayout const & operator[](size_type i) const {
447 return layoutlist[i];
451 bool delete_layout(string const &);
453 bool do_readStyle(LyXLex &, LyXLayout &);
460 /// Specific class options
461 string opt_fontsize_;
463 string opt_pagestyle_;
473 unsigned int columns_;
481 OutputType outputType_;
482 /** Base font. The paragraph and layout fonts are resolved against
483 this font. This has to be fully instantiated. Attributes
484 LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
487 LyXFont defaultfont_;
488 /// Text that dictates how wide the left margin is on the screen
491 /// Text that dictates how wide the right margin is on the screen
494 int maxcounter_; // add approp. signedness
497 LayoutList layoutlist;
499 /// Has this layout file been loaded yet?
506 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
508 p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
513 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
517 class LyXTextClassList {
520 typedef std::vector<LyXTextClass> ClassList;
522 typedef ClassList::const_iterator const_iterator;
524 typedef ClassList::size_type size_type;
526 const_iterator begin() const { return classlist.begin(); }
528 const_iterator end() const { return classlist.end(); }
530 /// Gets layout structure from layout number and textclass number
531 LyXLayout const & Style(size_type textclass,
532 LyXTextClass::size_type layout) const;
534 /// Gets layout number from textclass number and layout name
535 std::pair<bool, LyXTextClass::size_type>
536 NumberOfLayout(size_type textclass,
537 string const & name) const;
539 /// Gets a layout name from layout number and textclass number
541 NameOfLayout(size_type textclass,
542 LyXTextClass::size_type layout) const;
544 /** Gets textclass number from name.
545 Returns -1 if textclass name does not exist
547 std::pair<bool, size_type>
548 NumberOfClass(string const & textclass) const;
551 string const & NameOfClass(size_type number) const;
554 string const & LatexnameOfClass(size_type number) const;
557 string const & DescOfClass(size_type number) const;
560 LyXTextClass const & TextClass(size_type textclass) const;
562 /** Read textclass list.
563 Returns false if this fails
568 Returns false if this fails
570 bool Load(size_type number) const;
573 mutable ClassList classlist;
575 void Add (LyXTextClass const &);
578 /// Should not be declared here!! (Lgb) Why not? (Asger)
579 extern LyXTextClassList textclasslist;