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 "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 VFILL, 35 LENGTH ///< user-defined length 36 }; 37 38 /// 39 VSpace(); 40 /// 41 explicit VSpace(VSpaceKind k); 42 /// 43 explicit VSpace(Length const & l); 44 /// 45 explicit VSpace(GlueLength const & l); 46 47 /// Constructor for reading from a .lyx file 48 explicit VSpace(std::string const & data); 49 50 /// return the type of vertical space kind()51 VSpaceKind kind() const { return kind_; } 52 /// return the length of this space length()53 GlueLength const & length() const { return len_; } 54 55 /// a flag that switches between \vspace and \vspace* keep()56 bool keep() const { return keep_; } 57 /// if set true, use \vspace* when type is not DEFSKIP setKeep(bool keep)58 void setKeep(bool keep) { keep_ = keep; } 59 /// 60 bool operator==(VSpace const &) const; 61 62 // conversion 63 64 /// how it goes into the LyX file 65 std::string const asLyXCommand() const; 66 /// the latex representation 67 std::string const asLatexCommand(BufferParams const & params) const; 68 /// 69 std::string asHTMLLength() const; 70 /// how it is seen in the LyX window 71 docstring const asGUIName() const; 72 /// the size of the space on-screen 73 int inPixels(BufferView const & bv) const; 74 75 private: 76 /// This VSpace kind 77 VSpaceKind kind_; 78 /// the specified length 79 GlueLength len_; 80 /// if true, use \vspace* type 81 bool keep_; 82 }; 83 84 85 } // namespace lyx 86 87 #endif // VSPACE_H 88