]> git.lyx.org Git - lyx.git/blob - src/lyxgluelength.h
Make enter button work in GTK text dialog
[lyx.git] / src / lyxgluelength.h
1 // -*- C++ -*-
2 /**
3  * \file lyxgluelength.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  * \author Matthias Ettrich
9  * \author Jean-Marc Lasgouttes
10  *
11  * Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef LYX_GLUE_LENGTH_H
15 #define LYX_GLUE_LENGTH_H
16
17 #include "lyxlength.h"
18
19
20 class LyXGlueLength {
21 public:
22         ///
23         LyXGlueLength() {}
24         ///
25         explicit LyXGlueLength(LyXLength const & len);
26         ///
27         LyXGlueLength(LyXLength const & len,
28                       LyXLength const & plus,
29                       LyXLength const & minus);
30
31         /** "data" must be a decimal number, followed by a unit, and
32           optional "glue" indicated by "+" and "-".  You may abbreviate
33           reasonably.  Examples:
34           1.2 cm  //  4mm +2pt  //  2cm -4mm +2mm  //  4+0.1-0.2cm
35           The traditional Latex format is also accepted, like
36           4cm plus 10pt minus 10pt */
37         explicit LyXGlueLength(std::string const & data);
38
39         ///
40         LyXLength const & len() const;
41         ///
42         LyXLength const & plus() const;
43         ///
44         LyXLength const & minus() const;
45
46
47         /// conversion
48         std::string const asString() const;
49         ///
50         std::string const asLatexString() const;
51
52         friend bool isValidGlueLength(std::string const & data,
53                                       LyXGlueLength* result);
54
55 private:
56         /// the normal vlaue
57         LyXLength len_;
58         /// extra stretch
59         LyXLength plus_;
60         /// extra shrink
61         LyXLength minus_;
62 };
63
64 ///
65 bool operator==(LyXGlueLength const & l1, LyXGlueLength const & l2);
66 ///
67 bool operator!=(LyXGlueLength const & l1, LyXGlueLength const & l2);
68 /** If "data" is valid, the length represented by it is
69     stored into "result", if that is not 0. */
70 bool isValidGlueLength(std::string const & data, LyXGlueLength * result = 0);
71
72 #endif // LYXGLUELENGTH_H