]> git.lyx.org Git - lyx.git/blob - src/Spacing.h
Avoid full metrics computation with Update:FitCursor
[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 "support/strfwd.h"
16
17 #include <string>
18
19 namespace lyx {
20
21 ///
22 class Spacing {
23 public:
24         ///
25         enum Space {
26                 ///
27                 Single,
28                 ///
29                 Onehalf,
30                 ///
31                 Double,
32                 ///
33                 Other,
34                 ///
35                 Default
36         };
37         ///
38         Spacing() : space(Default), value("1.0") {}
39         ///
40         Spacing(Spacing::Space sp, double val = 1.0) { set(sp, val); }
41         ///
42         Spacing(Spacing::Space sp, std::string const & val) { set(sp, val); }
43         ///
44         bool isDefault() const { return space == Default; }
45         ///
46         std::string const getValueAsString() const;
47         ///
48         double getValue() const;
49         ///
50         Spacing::Space getSpace() const { return space; }
51         ///
52         void set(Spacing::Space sp, double val = 1.0);
53         ///
54         void set(Spacing::Space sp, std::string const & val);
55         ///
56         void writeFile(std::ostream &, bool para = false) const;
57         /// useSetSpace is true when using the variant supported by
58         /// the memoir class.
59         std::string const writeEnvirBegin(bool useSetSpace) const;
60         /// useSetSpace is true when using the variant supported by
61         /// the memoir class.
62         std::string const writeEnvirEnd(bool useSetSpace) const;
63         /// useSetSpace is true when using the variant supported by
64         /// the memoir class.
65         std::string const writeCmd(bool useSetSpace) const;
66         /// useSetSpace is true when using the variant supported by
67         /// the memoir class.
68         std::string const writePreamble(bool useSetSpace) const;
69
70 private:
71         ///
72         Space space;
73         ///
74         std::string value;
75         /// names of line spacing
76         static std::string const spacing_string[];
77 };
78
79
80 ///
81 inline
82 bool operator==(Spacing const & a, Spacing const & b)
83 {
84         return a.getSpace() == b.getSpace()
85                 && a.getValueAsString() == b.getValueAsString();
86 }
87
88 ///
89 inline
90 bool operator!=(Spacing const & a, Spacing const & b)
91 {
92         return !(a == b);
93 }
94
95 } // namespace lyx
96
97 #endif // SPACING_H