]> git.lyx.org Git - lyx.git/blobdiff - src/layout.h
More ascii-export fixes and when making copy of single tabular cells now the
[lyx.git] / src / layout.h
index 9125c3fc44e3d45beaac99827814c62e2d6d60a6..51f4af3bcb2b4a3f43c709eafcdcc53e4ea736f8 100644 (file)
@@ -5,44 +5,44 @@
  *           LyX, The Document Processor
  *      
  *           Copyright 1995 Matthias Ettrich
- *           Copyright 1995-2000 The LyX Team.
+ *           Copyright 1995-2001 The LyX Team.
  *
  * ====================================================== */
 
 #ifndef LAYOUT_H
 #define LAYOUT_H
 
+#include <vector>
+
 #ifdef __GNUG__
 #pragma interface
 #endif
 
-#include "lyxlex.h"
 #include "lyxfont.h"
 #include "Spacing.h"
+#include "support/types.h"
+#include <boost/utility.hpp>
 
-#include <vector>
-using std::vector;
-using std::pair;
+class LyXLeX;
 
 /// Reads the style files
 extern void LyXSetStyle();
 
-///
-enum { // no good name for this
-       ///
-        LYX_ENVIRONMENT_DEFAULT = 97,
+enum layout_default {
        ///
        LYX_LAYOUT_DEFAULT = 99
 };
+
 // Could this cause confusion that both DUMMY_LAYOUT and  LAYOUT_DEFAULT has
 // the same value? (Lgb)
 ///
 #define LYX_DUMMY_LAYOUT 99
 
+
 /// The different output types
 enum OutputType {
-        ///
-        LATEX = 1,
+       ///
+       LATEX = 1,
        ///
        LINUXDOC,
        ///
@@ -51,6 +51,7 @@ enum OutputType {
        LITERATE
 };
 
+
 /// The different margin types
 enum LYX_MARGIN_TYPE {
        ///
@@ -81,15 +82,16 @@ enum LyXAlignment {
        ///
        LYX_ALIGN_LAYOUT = 16,
        ///
-        LYX_ALIGN_SPECIAL = 32
+       LYX_ALIGN_SPECIAL = 32
 };
 
-
+///
 inline
 void operator|=(LyXAlignment & la1, LyXAlignment la2) {
        la1 = static_cast<LyXAlignment>(la1 | la2);
 }
 
+
 /// The different LaTeX-Types
 enum LYX_LATEX_TYPES {
        ///
@@ -104,6 +106,7 @@ enum LYX_LATEX_TYPES {
        LATEX_LIST_ENVIRONMENT
 };
 
+
 /// The different label types
 enum LYX_LABEL_TYPES {
        ///
@@ -111,7 +114,7 @@ enum LYX_LABEL_TYPES {
        ///
        LABEL_MANUAL,
        ///
-        LABEL_BIBLIO,
+       LABEL_BIBLIO,
        ///
        LABEL_TOP_ENVIRONMENT,
        ///
@@ -141,11 +144,11 @@ enum LYX_LABEL_TYPES {
        ///
        LABEL_COUNTER_ENUMIII,
        ///
-       LABEL_COUNTER_ENUMIV,
-       ///
-       LABEL_FIRST_COUNTER = LABEL_COUNTER_CHAPTER
+       LABEL_COUNTER_ENUMIV
 };
 
+
+///
 enum LYX_END_LABEL_TYPES {
        ///
        END_LABEL_NO_LABEL,
@@ -154,9 +157,11 @@ enum LYX_END_LABEL_TYPES {
        ///
        END_LABEL_FILLED_BOX,
        ///
+       END_LABEL_STATIC,
+       ///
        END_LABEL_ENUM_FIRST = END_LABEL_NO_LABEL,
        ///
-       END_LABEL_ENUM_LAST = END_LABEL_FILLED_BOX
+       END_LABEL_ENUM_LAST = END_LABEL_STATIC
 };
                
 /* Fix labels are printed flushright, manual labels flushleft. 
@@ -179,7 +184,7 @@ enum LYX_END_LABEL_TYPES {
  */ 
 
 
-/// Attributes of a layout/paragraph environment
+// Attributes of a layout/paragraph environment
 class LyXTextClass;
 
 ///
@@ -190,20 +195,37 @@ public:
 
        ///
        bool Read (LyXLex &, LyXTextClass const &);
+       ///
        void readAlign(LyXLex &);
+       ///
        void readAlignPossible(LyXLex &);
+       ///
        void readLabelType(LyXLex &);
+       ///
        void readEndLabelType(LyXLex &);
+       ///
        void readMargin(LyXLex &);
+       ///
        void readLatexType(LyXLex &);
+       ///
        void readSpacing(LyXLex &);
+       ///
        string const & name() const { return name_; }
-       void name(string const & n) { name_ = n; }
+       ///
+       void setName(string const & n) { name_ = n; }
+       ///
        string const & obsoleted_by() const { return obsoleted_by_; }
+       ///
        string const & latexname() const { return latexname_; }
+       ///
        string const & labelstring() const { return labelstring_; }
+       ///
+       string const & endlabelstring() const { return endlabelstring_; }
+       ///
        string const & preamble() const { return preamble_; }
+       ///
        string const & latexparam() const { return latexparam_; }
+       ///
        string const & labelstring_appendix() const {
                return labelstring_appendix_;
        }
@@ -282,7 +304,7 @@ public:
        char labeltype; // add approp. type
 
        ///
-       char endlabeltype;
+       LYX_END_LABEL_TYPES endlabeltype;
 
        ///
        LYX_MARGIN_TYPE margintype;
@@ -301,8 +323,12 @@ public:
 
        ///
        bool free_spacing;
-       /// true when the fragile commands in the paragraph need to be
-       /// \protect'ed.
+
+       ///
+       bool pass_thru;
+
+       /** true when the fragile commands in the paragraph need to be
+           \protect'ed. */
        bool needprotect;
        /// true when empty paragraphs should be kept.
        bool keepempty;
@@ -340,13 +366,16 @@ private:
        /// Label string. "Abstract", "Reference", "Caption"...
        string labelstring_;
 
+       ///
+       string endlabelstring_;
+
        /// Label string inside appendix. "Appendix", ...
        string labelstring_appendix_;
 
        /// LaTeX parameter for environment
-        string latexparam_;
+       string latexparam_;
 
-        /// Macro definitions needed for this layout
+       /// Macro definitions needed for this layout
        string preamble_;
 };
 
@@ -355,12 +384,11 @@ private:
 class LyXTextClass {
 public:
        ///
-       typedef vector<LyXLayout> LayoutList;
+       typedef std::vector<LyXLayout> LayoutList;
        ///
        typedef LayoutList::const_iterator const_iterator;
        ///
-       typedef LayoutList::size_type size_type;
-       ///
+       explicit
        LyXTextClass (string const & = string(), 
                      string const & = string(), 
                      string const & = string());
@@ -372,8 +400,11 @@ public:
        
        ///
        bool Read(string const & filename, bool merge = false);
+       ///
        void readOutputType(LyXLex &);
+       ///
        void readMaxCounter(LyXLex &);
+       ///
        void readClassOptions(LyXLex &);
        ///
        bool hasLayout(string const & name) const;
@@ -406,18 +437,25 @@ public:
 
        /// Packages that are already loaded by the class
        enum Provides {
+               ///
                nothing = 0,
+               ///
                amsmath = 1,
+               ///
                makeidx = 2,
+               ///
                url = 4
        };
+       ///
        bool provides(Provides p) const { return provides_ & p; }
        
        ///
        unsigned int columns() const { return columns_; }
        ///
        enum PageSides {
+               ///
                OneSide,
+               ///
                TwoSides
        };
        ///
@@ -427,8 +465,8 @@ public:
        ///
        int tocdepth() const { return tocdepth_; }
 
-        ///
-        OutputType outputType() const { return outputType_; }
+       ///
+       OutputType outputType() const { return outputType_; }
 
        ///
        LyXFont const & defaultfont() const { return defaultfont_; }
@@ -441,9 +479,9 @@ public:
         ///
        int maxcounter() const { return maxcounter_; }
        ///
-       size_type numLayouts() const { return layoutlist.size(); }
+       lyx::layout_type numLayouts() const { return layoutlist.size(); }
        ///
-       LyXLayout const & operator[](size_type i) const {
+       LyXLayout const & operator[](lyx::layout_type i) const {
                return layoutlist[i];
        }
 private:
@@ -458,9 +496,9 @@ private:
        ///
        string description_;
        /// Specific class options
-        string opt_fontsize_;
+       string opt_fontsize_;
        ///
-        string opt_pagestyle_;
+       string opt_pagestyle_;
        ///
        string options_;
        ///
@@ -477,8 +515,8 @@ private:
        int secnumdepth_;
        ///
        int tocdepth_;
-        ///
-        OutputType outputType_;
+       ///
+       OutputType outputType_;
        /** Base font. The paragraph and layout fonts are resolved against
            this font. This has to be fully instantiated. Attributes
            LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
@@ -490,7 +528,7 @@ private:
 
        /// Text that dictates how wide the right margin is on the screen
        string rightmargin_;
-        ///
+       ///
        int maxcounter_; // add approp. signedness
 
        ///
@@ -500,7 +538,6 @@ private:
        bool loaded;
 };
 
-
 ///
 inline
 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
@@ -510,66 +547,50 @@ void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
 
 
 ///
-inline
-ostream & operator<<(ostream & os, LyXTextClass::PageSides p)
-{
-       switch (p) {
-       case LyXTextClass::OneSide:
-               os << "1";
-               break;
-       case LyXTextClass::TwoSides:
-               os << "2";
-               break;
-       }
-       return os;
-}
+std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
 
 
 ///
-class LyXTextClassList {
+class LyXTextClassList : boost::noncopyable {
 public:
        ///
-       typedef vector<LyXTextClass> ClassList;
+       typedef std::vector<LyXTextClass> ClassList;
        ///
        typedef ClassList::const_iterator const_iterator;
        ///
-       typedef ClassList::size_type size_type;
-       ///
        const_iterator begin() const { return classlist.begin(); }
        ///
        const_iterator end() const { return classlist.end(); }
        
        /// Gets layout structure from layout number and textclass number
-       LyXLayout const & Style(size_type textclass,
-                               LyXTextClass::size_type layout) const;
+       LyXLayout const & Style(lyx::textclass_type textclass,
+                               lyx::layout_type layout) const;
 
        /// Gets layout number from textclass number and layout name
-       pair<bool, LyXTextClass::size_type>
-       NumberOfLayout(size_type textclass,
-                      string const & name) const;
+       std::pair<bool, lyx::layout_type> const
+       NumberOfLayout(lyx::textclass_type textclass, string const & name) const;
 
        /// Gets a layout name from layout number and textclass number
        string const &
-       NameOfLayout(size_type textclass,
-                    LyXTextClass::size_type layout) const;
+       NameOfLayout(lyx::textclass_type textclass, lyx::layout_type layout) const;
 
        /** Gets textclass number from name.
            Returns -1 if textclass name does not exist
        */
-       pair<bool, size_type>
+       std::pair<bool, lyx::textclass_type> const
        NumberOfClass(string const & textclass) const;
 
        ///
-       string const & NameOfClass(size_type number) const;
+       string const & NameOfClass(lyx::textclass_type number) const;
 
        ///
-       string const & LatexnameOfClass(size_type number) const;
+       string const & LatexnameOfClass(lyx::textclass_type number) const;
 
        ///
-       string const & DescOfClass(size_type number) const;
+       string const & DescOfClass(lyx::textclass_type number) const;
 
        ///
-       LyXTextClass const & TextClass(size_type textclass) const;
+       LyXTextClass const & TextClass(lyx::textclass_type textclass) const;
 
        /** Read textclass list.
            Returns false if this fails
@@ -579,7 +600,7 @@ public:
        /** Load textclass.
            Returns false if this fails
        */
-       bool Load(size_type number) const;
+       bool Load(lyx::textclass_type number) const;
 private:
        ///
        mutable ClassList classlist;
@@ -587,7 +608,7 @@ private:
        void Add (LyXTextClass const &);
 };
 
-/// Should not be declared here!! (Lgb) Why not? (Asger)
+/// 
 extern LyXTextClassList textclasslist;
  
 #endif