4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
15 #include "support/types.h"
21 /// Simple wrapper around three ints
25 Dimension() : wid(0), asc(0), des(0) {}
27 Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {}
29 Dimension(LyXFont const & font, char_type c) { set(font, c); }
31 Dimension & operator=(Dimension const & dim) {
38 void operator+=(Dimension const & dim);
40 void clear() { wid = asc = des = 0; }
41 /// set to empty box suitble for given font.
42 void clear(LyXFont const & font);
43 /// set to a char dimensions for a given font.
44 void set(LyXFont const & font, char_type c);
47 int height() const { return asc + des; }
49 int ascent() const { return asc; }
51 int descent() const { return des; }
53 int width() const { return wid; }
55 /// add space for a frame
56 //void addFrame(int frame) const;
57 /// add space for bottom part of a frame
58 //void addFrameBottom(int frame) const;
61 /// these are intentionally public as things like
65 /// are used all over the place and "hiding" those behind
67 /// dim.ascent(dim.ascent() + 20);
69 /// makes the code neither faster nor clearer
79 bool operator==(Dimension const & a, Dimension const & b)
81 return a.wid == b.wid && a.asc == b.asc && a.des == b.des ;
86 bool operator!=(Dimension const & a, Dimension const & b)
88 return a.wid != b.wid || a.asc != b.asc || a.des != b.des ;