]> git.lyx.org Git - lyx.git/blob - src/Spacing.h
STLPort compile fix
[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, float 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         float getValue() const;
50         ///
51         Spacing::Space getSpace() const { return space; }
52         ///
53         void set(Spacing::Space sp, float val = 1.0);
54         ///
55         void set(Spacing::Space sp, std::string const & val) ;
56         ///
57         void writeFile(std::ostream &, bool para = false) const;
58         ///
59         std::string const writeEnvirBegin() const;
60         ///
61         std::string const writeEnvirEnd() const;
62
63 private:
64         ///
65         Space space;
66         ///
67         float value;
68         /// names of line spacing
69         static std::string const spacing_string[];
70 };
71
72
73 ///
74 inline
75 bool operator==(Spacing const & a, Spacing const & b)
76 {
77         return a.getSpace() == b.getSpace()
78                 && a.getValue() == b.getValue();
79 }
80
81 ///
82 inline
83 bool operator!=(Spacing const & a, Spacing const & b)
84 {
85         return !(a == b);
86 }
87 #endif