]> git.lyx.org Git - lyx.git/blobdiff - src/vspace.h
update no.po
[lyx.git] / src / vspace.h
index 8fda0c3f5ed2ffa5e0208b5a37beaa0b9d477290..5164c20d22d761e08e6c20d0a0c87d5d7ccf712c 100644 (file)
@@ -1,13 +1,11 @@
 // -*- C++ -*-
-/* This file is part of
- * ====================================================== 
- * 
- *           LyX, The Document Processor
- *      
- *         Copyright (C) 1995 1996 Matthias Ettrich
- *           and the LyX Team.
+/**
+ * \file vspace.h
+ * Copyright 1995-2002 the LyX Team
+ * Read the file COPYING
  *
- * ====================================================== */
+ * \author Matthias Ettrich
+ */
 
 #ifndef VSPACE_H
 #define VSPACE_H
 #pragma interface
 #endif
 
-#include "LString.h"
-
-///  LyXLength Class
-class LyXLength {
-public:
-       /// length units
-       enum UNIT {
-               /// Scaled point (65536sp = 1pt) TeX's smallest unit.
-               SP,
-               /// Point = 1/72.27in = 0.351mm
-               PT,
-               /// Big point (72bp = 1in), also PostScript point
-               BP,
-               /// Didot point = 1/72 of a French inch, = 0.376mm
-               DD,
-               /// Millimeter = 2.845pt
-               MM,
-               /// Pica = 12pt = 4.218mm
-               PC,
-               /// Cicero = 12dd = 4.531mm
-               CC,
-               /// Centimeter = 10mm = 2.371pc
-               CM,
-               /// Inch = 25.4mm = 72.27pt = 6.022pc
-               IN,
-               /// Height of a small "x" for the current font.
-               EX,
-               /// Width of capital "M" in current font.
-               EM,
-               /// Math unit (18mu = 1em) for positioning in math mode
-               MU,
-               /// no unit
-               UNIT_NONE
-       };
-
-       //@Man: constructors
-       //@{
-       ///
-       LyXLength() : val(0), uni(LyXLength::PT) {}
-       LyXLength(float v, LyXLength::UNIT u) : val(v), uni(u) {}
-
-       /** "data" must be a decimal number, followed by a unit. */
-        LyXLength(string const & data);
-       //@}
-       
-       //@Man: selectors
-       //@{
-       ///
-       float value() const         { return val; };
-       ///
-       LyXLength::UNIT unit() const { return uni; };
-       //@}
-
-       ///
-        bool operator== (LyXLength const &) const;
-
-       /// conversion
-       virtual string asString() const;
-       ///
-       virtual string asLatexString() const { return this->asString(); };
-
+#include "lyxgluelength.h"
 
-       /** If "data" is valid, the length represented by it is
-         stored into "result", if that is not 0. */
-       friend bool isValidLength(string const & data, 
-                                 LyXLength * result= 0);
+#include "LString.h"
 
-protected:
-       ///
-       float           val;
-       ///
-       LyXLength::UNIT uni;
-};
+class BufferParams;
+class BufferView;
 
-extern LyXLength::UNIT unitFromString (string const & data);
-extern bool isValidLength(string const & data, LyXLength * result);
 
-/// LyXGlueLength class
-class LyXGlueLength : public LyXLength {
+/// A class representing latex vertical spacing
+class VSpace {
 public:
-       //@Man: constructors
-       //@{
-       ///
-       LyXGlueLength(float v,      LyXLength::UNIT u, 
-                     float pv= 0.0, LyXLength::UNIT pu= LyXLength::UNIT_NONE, 
-                     float mv= 0.0, LyXLength::UNIT mu= LyXLength::UNIT_NONE) 
-               : LyXLength (v, u), 
-                 plus_val(pv), minus_val(mv), 
-                 plus_uni(pu), minus_uni(mu) {}
-
-       /** "data" must be a decimal number, followed by a unit, and 
-         optional "glue" indicated by "+" and "-".  You may abbreviate
-         reasonably.  Examples:
-         1.2 cm  //  4mm +2pt  //  2cm -4mm +2mm  //  4+0.1-0.2cm
-         The traditional Latex format is also accepted, like  
-         4cm plus 10pt minus 10pt */
-        LyXGlueLength(string const & data);
-       //@}
-       
-       //@Man: selectors
-       //@{
-       ///
-       float plusValue() const         { return plus_val; };
-       ///
-       LyXLength::UNIT plusUnit() const { return plus_uni; };
-       ///
-       float minusValue() const         { return minus_val; };
-       ///
-       LyXLength::UNIT minusUnit() const { return minus_uni; };
-       //@}
+       /// The different kinds of spaces.
+       enum vspace_kind {
+               NONE, ///< no added vertical space
+               DEFSKIP,
+               SMALLSKIP,
+               MEDSKIP,
+               BIGSKIP,
+               VFILL,
+               LENGTH ///< user-defined length
+       };
 
-       ///
-        bool operator == (LyXGlueLength const &) const;
+       VSpace();
 
-       /// conversion
-       virtual string asString() const;
-       ///
-       virtual string asLatexString() const;
+       explicit VSpace(vspace_kind k);
 
+       explicit VSpace(LyXLength const & l);
 
-       /** If "data" is valid, the length represented by it is
-         stored into "result", if that is not 0. */
-       friend bool isValidGlueLength(string const & data, 
-                                     LyXGlueLength* result= 0);
+       explicit VSpace(LyXGlueLength const & l);
 
-protected:
-       ///
-       float           plus_val, minus_val;
-       ///
-       LyXLength::UNIT plus_uni, minus_uni;
-};
+       /// Constructor for reading from a .lyx file
+       explicit VSpace(string const & data);
 
-extern bool isValidGlueLength(string const & data, LyXGlueLength * result);
-
-///  VSpace class
-class VSpace {
-public:
-       ///
-       enum vspace_kind { NONE, DEFSKIP, 
-                          SMALLSKIP, MEDSKIP, BIGSKIP, 
-                          VFILL, LENGTH };
-       // constructors
-       VSpace() : 
-               kin (NONE), 
-               len(0.0, LyXLength::PT),
-                kp (false) {}
-
-       VSpace(vspace_kind k) : 
-               kin (k), 
-               len (0.0, LyXLength::PT),
-               kp (false) {}
-
-       VSpace(LyXGlueLength l) :
-               kin (LENGTH),
-               len (l),
-               kp (false) {}
-
-       VSpace(float v, LyXLength::UNIT u) : 
-               kin (LENGTH), 
-               len (v, u),
-               kp (false) {}
-
-       /// this constructor is for reading from a .lyx file
-       VSpace(string const & data);
-       
-       // access functions
-       vspace_kind kind() const  { return  kin; }
-       ///
-       LyXLength   length() const { return len; }
+       /// return the type of vertical space
+       vspace_kind kind() const;
+       /// return the length of this space
+       LyXGlueLength length() const;
 
        // a flag that switches between \vspace and \vspace*
-        bool keep() const      { return kp; }
-       ///
-       void setKeep(bool val) { kp = val; } 
+       bool keep() const;
+       /// if set true, use \vspace* when type is not DEFSKIP
+       void setKeep(bool val);
        ///
-        bool operator == (VSpace const &) const;
+       bool operator==(VSpace const &) const;
 
        // conversion
-       ///
-       string asLyXCommand() const;  // how it goes into the LyX file
-       ///
-       string asLatexCommand() const;
-       ///
-       int inPixels() const;
+
+       /// how it goes into the LyX file
+       string const asLyXCommand() const;
+       /// the latex representation
+       string const asLatexCommand(BufferParams const & params) const;
+       /// the size of the space on-screen
+       int inPixels(BufferView const * bv) const;
 private:
-       ///
-       vspace_kind  kin;
-       ///
-       LyXGlueLength    len;
-       ///
-       bool kp;
+       /// This VSpace kind
+       vspace_kind kind_;
+       /// the specified length
+       LyXGlueLength len_;
+       /// if true, use \vspace* type
+       bool keep_;
 };
 
-#endif
+#endif // VSPACE_H