This commit was manufactured by cvs2svn to create tag
[lyx.git] / src / Spacing.h
blob3bbc85282b84600c632ff51caa9ba602b44f4f9e
1 // -*- C++ -*-
2 /* This file is part of
3 * ======================================================
4 *
5 * LyX, The Document Processor
6 *
7 * Copyright 1995 Matthias Ettrich
8 * Copyright 1995-1999 The LyX Team.
10 * ======================================================*/
12 #ifndef SPACING_H
13 #define SPACING_H
15 #include <cstdio>
17 ///
18 class Spacing {
19 public:
20 ///
21 enum Space {
22 ///
23 Single,
24 ///
25 Onehalf,
26 ///
27 Double,
28 ///
29 Other
31 ///
32 Spacing()
34 space = Single;
35 value = getValue();
37 ///
38 float getValue() const
40 switch(space) {
41 case Single: return 1.0;
42 case Onehalf: return 1.25;
43 case Double: return 1.667;
44 case Other: return value;
46 return 1.0;
48 ///
49 Spacing::Space getSpace() const
51 return space;
53 ///
54 void set(Spacing::Space sp, float val= 1.0)
56 space = sp;
57 if (sp == Other) {
58 switch(int(val*1000 + 0.5)) {
59 case 1000: space = Single; break;
60 case 1250: space = Onehalf; break;
61 case 1667: space = Double; break;
62 default: value = val; break;
66 ///
67 void set(Spacing::Space sp, char const* val)
69 float fval;
70 sscanf(val,"%f",&fval);
71 set(sp,fval);
73 ///
74 void writeFile(FILE *file);
75 ///
76 friend bool operator!=(Spacing const &a, Spacing const &b)
78 if (a.space == b.space && a.getValue() == b.getValue())
79 return false;
80 return true;
82 private:
83 ///
84 Space space;
85 ///
86 float value;
89 #endif