]> git.lyx.org Git - lyx.git/blob - src/lyxtextclass.h
move counters to the layout files
[lyx.git] / src / lyxtextclass.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef LYXTEXTCLASS_H
13 #define LYXTEXTCLASS_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "lyxlayout.h"
20 #include "LString.h"
21 #include "lyxlayout_ptr_fwd.h"
22 #include "FloatList.h"
23
24 #include "support/types.h"
25
26 #include <boost/shared_ptr.hpp>
27
28 #include <vector>
29
30 class LyXLex;
31 class Counters;
32
33 ///
34 class LyXTextClass {
35 public:
36         ///
37         typedef std::vector<LyXLayout_ptr> LayoutList;
38         ///
39         typedef LayoutList::const_iterator const_iterator;
40         ///
41         explicit
42         LyXTextClass(string const & = string(),
43                      string const & = string(),
44                      string const & = string());
45
46         ///
47         const_iterator begin() const { return layoutlist_.begin(); }
48         ///
49         const_iterator end() const { return layoutlist_.end(); }
50
51         ///
52         bool Read(string const & filename, bool merge = false);
53         ///
54         void readOutputType(LyXLex &);
55         ///
56         void readMaxCounter(LyXLex &);
57         ///
58         void readClassOptions(LyXLex &);
59         ///
60         void readFloat(LyXLex &);
61         ///
62         void readCounter(LyXLex &);
63         ///
64         bool hasLayout(string const & name) const;
65
66         ///
67         LyXLayout_ptr const & operator[](string const & vname) const;
68
69         /// Sees to that the textclass structure has been loaded
70         bool load() const;
71
72         /// the list of floats defined in the class
73         FloatList & floats();
74         /// the list of floats defined in the class
75         FloatList const & floats() const;
76         /// The Counters present in this textclass.
77         Counters & counters() const;
78         ///
79         string const & defaultLayoutName() const;
80         ///
81         LyXLayout_ptr const & defaultLayout() const;
82         ///
83         string const & name() const;
84         ///
85         string const & latexname() const;
86         ///
87         string const & description() const;
88         ///
89         string const & opt_fontsize() const;
90         ///
91         string const & opt_pagestyle() const;
92         ///
93         string const & options() const;
94         ///
95         string const & pagestyle() const;
96         ///
97         string const & preamble() const;
98
99         /// Packages that are already loaded by the class
100         enum Provides {
101                 ///
102                 nothing = 0,
103                 ///
104                 amsmath = 1,
105                 ///
106                 makeidx = 2,
107                 ///
108                 url = 4,
109                 ///
110                 natbib = 8
111         };
112         ///
113         bool provides(Provides p) const;
114
115         ///
116         unsigned int columns() const;
117         ///
118         enum PageSides {
119                 ///
120                 OneSide,
121                 ///
122                 TwoSides
123         };
124         ///
125         PageSides sides() const;
126         ///
127         int secnumdepth() const;
128         ///
129         int tocdepth() const;
130
131         ///
132         OutputType outputType() const;
133
134         ///
135         LyXFont const & defaultfont() const;
136
137         /// Text that dictates how wide the left margin is on the screen
138         string const & leftmargin() const;
139
140         /// Text that dictates how wide the right margin is on the screen
141         string const & rightmargin() const;
142         ///
143         int maxcounter() const;
144         ///
145         int size() const;
146 private:
147         ///
148         bool delete_layout(string const &);
149         ///
150         bool do_readStyle(LyXLex &, LyXLayout &);
151         ///
152         string name_;
153         ///
154         string latexname_;
155         ///
156         string description_;
157         /// Specific class options
158         string opt_fontsize_;
159         ///
160         string opt_pagestyle_;
161         ///
162         string options_;
163         ///
164         string pagestyle_;
165         ///
166         string defaultlayout_;
167         ///
168         string preamble_;
169         ///
170         Provides provides_;
171         ///
172         unsigned int columns_;
173         ///
174         PageSides sides_;
175         ///
176         int secnumdepth_;
177         ///
178         int tocdepth_;
179         ///
180         OutputType outputType_;
181         /** Base font. The paragraph and layout fonts are resolved against
182             this font. This has to be fully instantiated. Attributes
183             LyXFont::INHERIT, LyXFont::IGNORE, and LyXFont::TOGGLE are
184             extremely illegal.
185         */
186         LyXFont defaultfont_;
187         /// Text that dictates how wide the left margin is on the screen
188         string leftmargin_;
189
190         /// Text that dictates how wide the right margin is on the screen
191         string rightmargin_;
192         ///
193         int maxcounter_; // add approp. signedness
194
195         ///
196         LayoutList layoutlist_;
197
198         ///
199         FloatList floatlist_;
200
201         ///
202         boost::shared_ptr<Counters> ctrs_;
203
204         /// Has this layout file been loaded yet?
205         mutable bool loaded;
206 };
207
208
209 ///
210 inline
211 void operator|=(LyXTextClass::Provides & p1, LyXTextClass::Provides p2)
212 {
213         p1 = static_cast<LyXTextClass::Provides>(p1 | p2);
214 }
215
216
217 ///
218 std::ostream & operator<<(std::ostream & os, LyXTextClass::PageSides p);
219
220 #endif