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