]> git.lyx.org Git - lyx.git/blob - src/Spacing.h
move everything into namespace lyx
[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 #include <iosfwd>
16 #include <string>
17
18
19 namespace lyx {
20
21
22 ///
23 class Spacing {
24 public:
25         ///
26         enum Space {
27                 ///
28                 Single,
29                 ///
30                 Onehalf,
31                 ///
32                 Double,
33                 ///
34                 Other,
35                 ///
36                 Default
37         };
38         ///
39         Spacing() : space(Default), value("1.0") {}
40         ///
41         Spacing(Spacing::Space sp, double val = 1.0) {
42                 set(sp, val);
43         }
44         Spacing(Spacing::Space sp, std::string const & val) {
45                 set(sp, val);
46         }
47         ///
48         bool isDefault() const {
49                 return space == Default;
50         }
51         ///
52         std::string const getValueAsString() const;
53         ///
54         double getValue() const;
55         ///
56         Spacing::Space getSpace() const { return space; }
57         ///
58         void set(Spacing::Space sp, double val = 1.0);
59         ///
60         void set(Spacing::Space sp, std::string const & val);
61         ///
62         void writeFile(std::ostream &, bool para = false) const;
63         ///
64         std::string const writeEnvirBegin() const;
65         ///
66         std::string const writeEnvirEnd() 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