]> git.lyx.org Git - lyx.git/blobdiff - src/vspace.h
more changes, read the Changelog
[lyx.git] / src / vspace.h
index c33233d602822547c646c59c41f11503157247be..92ae53231921fe919f4e2c881f4f9f16a6ed63d5 100644 (file)
@@ -1,13 +1,13 @@
 // -*- C++ -*-
 /* This file is part of
- * ======================================================
+ * ====================================================== 
  * 
  *           LyX, The Document Processor
  *      
- *         Copyright (C) 1995 1996 Matthias Ettrich
- *           and the LyX Team.
+ *           Copyright 1995 Matthias Ettrich
+ *           Copyright 1995-2000 The LyX Team.
  *
- *======================================================*/
+ * ====================================================== */
 
 #ifndef VSPACE_H
 #define VSPACE_H
 #pragma interface
 #endif
 
-#include <cstdio>
+#include "LString.h"
+
+class BufferParams;
+class BufferView;
 
 ///  LyXLength Class
 class LyXLength {
@@ -58,6 +61,7 @@ public:
        LyXLength(float v, LyXLength::UNIT u) : val(v), uni(u) {}
 
        /** "data" must be a decimal number, followed by a unit. */
+       explicit
         LyXLength(string const & data);
        //@}
        
@@ -69,9 +73,6 @@ public:
        LyXLength::UNIT unit() const { return uni; };
        //@}
 
-       ///
-        bool operator==(LyXLength const &) const;
-
        /// conversion
        virtual string asString() const;
        ///
@@ -81,7 +82,7 @@ public:
        /** 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);
+                                 LyXLength * result= 0);
 
 protected:
        ///
@@ -90,6 +91,15 @@ protected:
        LyXLength::UNIT uni;
 };
 
+
+inline
+bool operator==(LyXLength const & l1, LyXLength const & l2)
+{
+       return l1.value() == l2.value()
+               && l1.unit() == l2.unit();
+}
+       
+
 extern LyXLength::UNIT unitFromString (string const & data);
 extern bool isValidLength(string const & data, LyXLength * result);
 
@@ -99,9 +109,12 @@ 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) 
+       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) {}
@@ -112,6 +125,7 @@ public:
          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 */
+       explicit
         LyXGlueLength(string const & data);
        //@}
        
@@ -127,9 +141,6 @@ public:
        LyXLength::UNIT minusUnit() const { return minus_uni; };
        //@}
 
-       ///
-        bool operator==(LyXGlueLength const &) const;
-
        /// conversion
        virtual string asString() const;
        ///
@@ -139,7 +150,7 @@ public:
        /** 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);
+                                     LyXGlueLength* result= 0);
 
 protected:
        ///
@@ -148,6 +159,20 @@ protected:
        LyXLength::UNIT plus_uni, minus_uni;
 };
 
+///
+inline
+bool operator==(LyXGlueLength const & l1, LyXGlueLength const & l2)
+{
+       return l1.value() == l2.value()
+               && l1.unit() == l2.unit()
+               && l1.plusValue() == l2.plusValue()
+               && l1.plusUnit() == l2.plusUnit()
+               && l1.minusValue() == l2.minusValue()
+               && l1.minusUnit() == l2.minusUnit();
+}
+
+
+
 extern bool isValidGlueLength(string const & data, LyXGlueLength * result);
 
 ///  VSpace class
@@ -157,28 +182,33 @@ public:
        enum vspace_kind { NONE, DEFSKIP, 
                           SMALLSKIP, MEDSKIP, BIGSKIP, 
                           VFILL, LENGTH };
-       // constructors
+       /// constructors
        VSpace() : 
                kin (NONE), 
                len(0.0, LyXLength::PT),
                 kp (false) {}
-
+       ///
+       explicit
        VSpace(vspace_kind k) : 
                kin (k), 
                len (0.0, LyXLength::PT),
                kp (false) {}
-
+       ///
+       explicit
        VSpace(LyXGlueLength l) :
                kin (LENGTH),
                len (l),
                kp (false) {}
 
+       ///
+       explicit
        VSpace(float v, LyXLength::UNIT u) : 
                kin (LENGTH), 
                len (v, u),
                kp (false) {}
 
        /// this constructor is for reading from a .lyx file
+       explicit
        VSpace(string const & data);
        
        // access functions
@@ -191,15 +221,17 @@ public:
        ///
        void setKeep(bool val) { kp = 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;
+       string asLatexCommand(BufferParams const & params) const;
+       ///
+       int inPixels(BufferView * bv) const;
        ///
-       int inPixels() const;
+       int inPixels(int default_height, int default_skip) const;
 private:
        ///
        vspace_kind  kin;
@@ -210,5 +242,3 @@ private:
 };
 
 #endif
-
-