Another minor change, but this should almost get us to the point that we
[lyx.git] / src / Dimension.h
blobbd8f10d8f259c64db33737f9f6acfe7ef6f19b60
1 // -*- C++ -*-
2 /**
3 * \file Dimension.h
4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author André Pönitz
9 * Full author contact details are available in file CREDITS.
12 #ifndef DIMENSION_H
13 #define DIMENSION_H
15 namespace lyx {
17 /// Simple wrapper around three ints
18 class Dimension {
19 public:
20 /// constructor
21 Dimension() : wid(0), asc(0), des(0) {}
22 /// initialize data
23 Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {}
25 Dimension & operator=(Dimension const & dim) {
26 wid = dim.wid;
27 asc = dim.asc;
28 des = dim.des;
29 return *this;
31 /// glue horizontally
32 void operator+=(Dimension const & dim);
33 /// set to empty box
34 void clear() { wid = asc = des = 0; }
35 /// get height
36 int height() const { return asc + des; }
37 /// get ascent
38 int ascent() const { return asc; }
39 /// get descent
40 int descent() const { return des; }
41 /// get width
42 int width() const { return wid; }
44 /// add space for a frame
45 //void addFrame(int frame) const;
46 /// add space for bottom part of a frame
47 //void addFrameBottom(int frame) const;
49 public:
50 /// these are intentionally public as things like
51 ///
52 /// dim.asc += 20;
53 ///
54 /// are used all over the place and "hiding" those behind
55 ///
56 /// dim.ascent(dim.ascent() + 20);
57 ///
58 /// makes the code neither faster nor clearer
59 /// width
60 int wid;
61 /// ascent
62 int asc;
63 /// descent
64 int des;
67 inline
68 bool operator==(Dimension const & a, Dimension const & b)
70 return a.wid == b.wid && a.asc == b.asc && a.des == b.des ;
74 inline
75 bool operator!=(Dimension const & a, Dimension const & b)
77 return a.wid != b.wid || a.asc != b.asc || a.des != b.des ;
80 class Point {
81 public:
82 Point()
83 : x_(0), y_(0)
86 Point(int x, int y);
88 int x_, y_;
91 } // namespace lyx
93 #endif