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