]> git.lyx.org Git - lyx.git/blob - src/Spacing.h
more latin1..utf8 schanges. all of src/* should be utf8 now
[lyx.git] / src / Spacing.h
1 // -*- C++ -*-
2 /**
3  * \file src/Spacing.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Lars Gullik Bjønnes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef SPACING_H
13 #define SPACING_H
14
15 #ifdef TEX2LYX
16 #include "tex2lyx/Spacing.h"
17 #else
18
19 #include "support/strfwd.h"
20
21 #include <string>
22
23 namespace lyx {
24
25 ///
26 class Spacing {
27 public:
28         ///
29         enum Space {
30                 ///
31                 Single,
32                 ///
33                 Onehalf,
34                 ///
35                 Double,
36                 ///
37                 Other,
38                 ///
39                 Default
40         };
41         ///
42         Spacing() : space(Default), value("1.0") {}
43         ///
44         Spacing(Spacing::Space sp, double val = 1.0) { set(sp, val); }
45         ///
46         Spacing(Spacing::Space sp, std::string const & val) { set(sp, val); }
47         ///
48         bool isDefault() const { return space == Default; }
49         ///
50         std::string const getValueAsString() const;
51         ///
52         double getValue() const;
53         ///
54         Spacing::Space getSpace() const { return space; }
55         ///
56         void set(Spacing::Space sp, double val = 1.0);
57         ///
58         void set(Spacing::Space sp, std::string const & val);
59         ///
60         void writeFile(std::ostream &, bool para = false) const;
61         /// useSetSpace is true when using the variant supported by
62         /// the memoir class.
63         std::string const writeEnvirBegin(bool useSetSpace) const;
64         /// useSetSpace is true when using the variant supported by
65         /// the memoir class.
66         std::string const writeEnvirEnd(bool useSetSpace) const;
67         /// useSetSpace is true when using the variant supported by
68         /// the memoir class.
69         std::string const writePreamble(bool useSetSpace) const;
70
71 private:
72         ///
73         Space space;
74         ///
75         std::string value;
76         /// names of line spacing
77         static std::string const spacing_string[];
78 };
79
80
81 ///
82 inline
83 bool operator==(Spacing const & a, Spacing const & b)
84 {
85         return a.getSpace() == b.getSpace()
86                 && a.getValueAsString() == b.getValueAsString();
87 }
88
89 ///
90 inline
91 bool operator!=(Spacing const & a, Spacing const & b)
92 {
93         return !(a == b);
94 }
95
96 } // namespace lyx
97
98 #endif // TEX2LYX
99 #endif // SPACING_H