]> git.lyx.org Git - lyx.git/blob - src/lyxgluelength.h
Yet another tweak from J�rgen.
[lyx.git] / src / lyxgluelength.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ======================================================
4  *
5  *           LyX, The Document Processor
6  *      
7  *           Copyright 1995 Matthias Ettrich
8  *           Copyright 1995-2001 The LyX Team.
9  *
10  * ====================================================== */
11
12 #ifndef LYX_GLUE_LENGTH_H
13 #define LYX_GLUE_LENGTH_H
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "lyxlength.h"
20
21 #include "LString.h"
22
23 class BufferParams;
24 class BufferView;
25
26
27 class LyXGlueLength {
28 public:
29         ///
30         LyXGlueLength() {}
31         ///
32         explicit LyXGlueLength(LyXLength const & len);
33         ///
34         LyXGlueLength(LyXLength const & len,
35                       LyXLength const & plus,
36                       LyXLength const & minus);
37
38         /** "data" must be a decimal number, followed by a unit, and
39           optional "glue" indicated by "+" and "-".  You may abbreviate
40           reasonably.  Examples:
41           1.2 cm  //  4mm +2pt  //  2cm -4mm +2mm  //  4+0.1-0.2cm
42           The traditional Latex format is also accepted, like
43           4cm plus 10pt minus 10pt */
44         explicit LyXGlueLength(string const & data);
45         
46         ///
47         LyXLength const & len() const;
48         ///
49         LyXLength const & plus() const;
50         ///
51         LyXLength const & minus() const;
52
53
54         /// conversion
55         string const asString() const;
56         ///
57         string const asLatexString() const;
58
59
60         /** If "data" is valid, the length represented by it is
61           stored into "result", if that is not 0. */
62         friend bool isValidGlueLength(string const & data,
63                                       LyXGlueLength* result = 0);
64
65 private:
66         /// the normal vlaue
67         LyXLength len_;
68         /// extra stretch
69         LyXLength plus_;
70         /// extra shrink
71         LyXLength minus_;
72 };
73
74 ///
75 bool operator==(LyXGlueLength const & l1, LyXGlueLength const & l2);
76 ///
77 bool operator!=(LyXGlueLength const & l1, LyXGlueLength const & l2);
78 ///
79 bool isValidGlueLength(string const & data, LyXGlueLength * result);
80
81 #endif