]> git.lyx.org Git - lyx.git/blob - src/Spacing.h
* src/Spacing.cpp (writeBeginEnv, writeEndEnv): add a bool parameter
[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 #include <string>
21
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
68 private:
69         ///
70         Space space;
71         ///
72         std::string value;
73         /// names of line spacing
74         static std::string const spacing_string[];
75 };
76
77
78 ///
79 inline
80 bool operator==(Spacing const & a, Spacing const & b)
81 {
82         return a.getSpace() == b.getSpace()
83                 && a.getValueAsString() == b.getValueAsString();
84 }
85
86 ///
87 inline
88 bool operator!=(Spacing const & a, Spacing const & b)
89 {
90         return !(a == b);
91 }
92
93 } // namespace lyx
94
95 #endif // TEX2LYX
96 #endif // SPACING_H