]> git.lyx.org Git - lyx.git/blob - src/graphics/GraphicsParams.C
Store an InsetBase & in MailInset.
[lyx.git] / src / graphics / GraphicsParams.C
1 /**
2  * \file GraphicsParams.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #include <cstdlib>
14
15 #include "GraphicsParams.h"
16 #include "Lsstream.h"
17 #include "lyxlength.h"
18
19 using std::abs;
20
21 namespace grfx {
22
23 Params::Params()
24         : display(ColorDisplay),
25           scale(100),
26           angle(0)
27 {}
28
29
30 bool operator==(Params const & a, Params const & b)
31 {
32         return (a.filename == b.filename &&
33                 a.display == b.display &&
34                 a.bb == b.bb &&
35                 a.scale == b.scale &&
36                 a.angle == b.angle);
37 }
38
39
40 bool operator!=(Params const & a, Params const & b)
41 {
42         return !(a == b);
43 }
44
45
46 BoundingBox::BoundingBox()
47         : xl(0), yb(0), xr(0), yt(0)
48 {}
49
50
51 BoundingBox::BoundingBox(string const & bb)
52         : xl(0), yb(0), xr(0), yt(0)
53 {
54         if (bb.empty())
55                 return;
56
57         std::istringstream is(bb.c_str());
58         string a, b, c, d;
59         is >> a >> b >> c >> d;
60
61         // inBP returns the length in Postscript points.
62         // Note further that there are 72 Postscript pixels per inch.
63         unsigned int const xl_tmp = abs(LyXLength(a).inBP());
64         unsigned int const yb_tmp = abs(LyXLength(b).inBP());
65         unsigned int const xr_tmp = abs(LyXLength(c).inBP());
66         unsigned int const yt_tmp = abs(LyXLength(d).inBP());
67
68         if (xr_tmp <= xl_tmp || yt_tmp <= yb_tmp)
69                 return;
70
71         xl = xl_tmp;
72         yb = yb_tmp;
73         xr = xr_tmp;
74         yt = yt_tmp;
75 }
76
77
78 bool BoundingBox::empty() const
79 {
80         return (!xl && !yb && !xr && !yt);
81 }
82
83
84 bool operator==(BoundingBox const & a, BoundingBox const & b)
85 {
86         return (a.xl == b.xl &&
87                 a.yb == b.yb &&
88                 a.xr == b.xr &&
89                 a.yt == b.yt);
90 }
91
92
93 bool operator!=(BoundingBox const & a, BoundingBox const & b)
94 {
95         return !(a == b);
96 }
97
98 } // namespace grfx