]> git.lyx.org Git - lyx.git/blob - src/Spacing.h
the convert patch
[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 ///
20 class Spacing {
21 public:
22         ///
23         enum Space {
24                 ///
25                 Single,
26                 ///
27                 Onehalf,
28                 ///
29                 Double,
30                 ///
31                 Other,
32                 ///
33                 Default
34         };
35         ///
36         Spacing() : space(Default), value("1.0") {}
37         ///
38         Spacing(Spacing::Space sp, double val = 1.0) {
39                 set(sp, val);
40         }
41         Spacing(Spacing::Space sp, std::string const & val) {
42                 set(sp, val);
43         }
44         ///
45         bool isDefault() const {
46                 return space == Default;
47         }
48         ///
49         std::string const getValueAsString() const;
50         ///
51         double getValue() const;
52         ///
53         Spacing::Space getSpace() const { return space; }
54         ///
55         void set(Spacing::Space sp, double val = 1.0);
56         ///
57         void set(Spacing::Space sp, std::string const & val);
58         ///
59         void writeFile(std::ostream &, bool para = false) const;
60         ///
61         std::string const writeEnvirBegin() const;
62         ///
63         std::string const writeEnvirEnd() const;
64
65 private:
66         ///
67         Space space;
68         ///
69         std::string value;
70         /// names of line spacing
71         static std::string const spacing_string[];
72 };
73
74
75 ///
76 inline
77 bool operator==(Spacing const & a, Spacing const & b)
78 {
79         return a.getSpace() == b.getSpace()
80                 && a.getValueAsString() == b.getValueAsString();
81 }
82
83 ///
84 inline
85 bool operator!=(Spacing const & a, Spacing const & b)
86 {
87         return !(a == b);
88 }
89 #endif