]> git.lyx.org Git - lyx.git/blob - src/VSpace.h
Avoid full metrics computation with Update:FitCursor
[lyx.git] / src / VSpace.h
1 // -*- C++ -*-
2 /**
3  * \file VSpace.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Matthias Ettrich
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef VSPACE_H
13 #define VSPACE_H
14
15 #include "support/Length.h"
16
17
18 namespace lyx {
19
20
21 class BufferParams;
22 class BufferView;
23
24
25 /// A class representing latex vertical spacing
26 class VSpace {
27 public:
28         /// The different kinds of spaces.
29         enum VSpaceKind {
30                 DEFSKIP,
31                 SMALLSKIP,
32                 MEDSKIP,
33                 BIGSKIP,
34                 HALFLINE,
35                 FULLLINE,
36                 VFILL,
37                 LENGTH ///< user-defined length
38         };
39
40         ///
41         VSpace();
42         ///
43         explicit VSpace(VSpaceKind k);
44         ///
45         explicit VSpace(Length const & l);
46         ///
47         explicit VSpace(GlueLength const & l);
48
49         /// Constructor for reading from a .lyx file
50         explicit VSpace(std::string const & data);
51
52         /// return the type of vertical space
53         VSpaceKind kind() const { return kind_; }
54         /// return the length of this space
55         GlueLength const & length() const { return len_; }
56
57         /// a flag that switches between \vspace and \vspace*
58         bool keep() const { return keep_; }
59         /// if set true, use \vspace* when type is not DEFSKIP
60         void setKeep(bool keep) { keep_ = keep; }
61         ///
62         bool operator==(VSpace const &) const;
63
64         // conversion
65
66         /// how it goes into the LyX file
67         std::string const asLyXCommand() const;
68         /// the latex representation
69         std::string const asLatexCommand(BufferParams const & params) const;
70         ///
71         std::string asHTMLLength() const;
72         /// how it is seen in the LyX window
73         docstring const asGUIName() const;
74         /// the size of the space on-screen
75         int inPixels(BufferView const & bv) const;
76
77 private:
78         /// This VSpace kind
79         VSpaceKind kind_;
80         /// the specified length
81         GlueLength len_;
82         /// if true, use \vspace* type
83         bool keep_;
84 };
85
86
87 } // namespace lyx
88
89 #endif // VSPACE_H