]> git.lyx.org Git - features.git/commitdiff
(Herbert): add a new method, inBP, to LyXLength.
authorAngus Leeming <leeming@lyx.org>
Thu, 11 Apr 2002 18:36:18 +0000 (18:36 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 11 Apr 2002 18:36:18 +0000 (18:36 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3974 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/lyxlength.C
src/lyxlength.h

index fd3850e39a77f727c2a9ae1b4b8a1ccb3e734c97..39925bdbfd658c426b7fa0636fec9223e7d64ce5 100644 (file)
@@ -1,3 +1,8 @@
+2002-03-28  Herbert Voss  <voss@lyx.org>
+
+       * lyxlength.[Ch]: add inBP() to get the right PS-point
+       units (BigPoint). With inPixels we have rounding errors
+
 2002-04-11  Juergen Vigna  <jug@sad.it>
 
        * text2.C (setCursorFromCoordinates): set iy to the right value.
index 67be44c917df7c0dba587c603acebdbc1e18846a..30b54e0b8de639c24c294ab5d6e75e5ecb34ba13 100644 (file)
@@ -238,6 +238,34 @@ int LyXLength::inPixels(int default_width, int default_height) const
 }
 
 
+int LyXLength::inBP() const
+{
+       // return any LyXLength value as a one with
+       // the PostScript point, called bp (big points)
+       double result = 0.0;
+       int val_sign = val_ < 0.0 ? -1 : 1;
+       switch (unit_) {
+       case LyXLength::CM:
+               // 1bp = 0.2835cm
+               result = val_ * 28.346;
+               break;
+       case LyXLength::MM:
+               // 1bp = 0.02835mm
+               result = val_ * 2.8346;
+               break;
+       case LyXLength::IN:
+               // 1pt = 1/72in
+               result = val_ * 72.0;
+               break;
+       default:
+               // no other than bp possible
+               result = val_;
+               break;
+       }
+       return static_cast<int>(result * val_sign + 0.5);
+}
+
+
 bool operator==(LyXLength const & l1, LyXLength const & l2)
 {
        return l1.value() == l2.value() && l1.unit() == l2.unit();
index 6c79982f2360fa3aa36cba9693a84833a29b2332..86fc8867690fae2c44a173b9ff93a280ef9e3ec4 100644 (file)
@@ -67,6 +67,8 @@ public:
        string const asLatexString() const;
        /// return the on-screen size of this length
        int inPixels(int default_width, int default_height) const;
+       /// return the on-screen size of this length of an image
+       int inBP() const;
 
        /** If "data" is valid, the length represented by it is
          stored into "result", if that is not 0. */