]> git.lyx.org Git - lyx.git/blob - src/dimension.h
hopefully fix tex2lyx linking.
[lyx.git] / src / dimension.h
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.
6  *
7  * \author André Pönitz
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #ifndef DIMENSION_H
13 #define DIMENSION_H
14
15
16 namespace lyx {
17
18 class LyXFont;
19
20 /// Simple wrapper around three ints
21 class Dimension {
22 public:
23         /// constructor
24         Dimension() : wid(0), asc(0), des(0) {}
25         /// initialize data
26         Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {}
27
28         /// glue horizontally
29         void operator+=(Dimension const & dim);
30         /// set to empty box
31         void clear() { wid = asc = des = 0; }
32         /// set to empty box suitble for given font
33         void clear(LyXFont const & font);
34         /// get height
35         int height() const { return asc + des; }
36         /// get ascent
37         int ascent() const { return asc; }
38         /// get descent
39         int descent() const { return des; }
40         /// get width
41         int width() const { return wid; }
42
43         /// add space for a frame
44         //void addFrame(int frame) const;
45         /// add space for bottom part of a frame
46         //void addFrameBottom(int frame) const;
47
48 public:
49         /// these are intentionally public as things like
50         ///
51         ///   dim.asc += 20;
52         ///
53         /// are used all over the place and "hiding" those behind
54         ///
55         ///   dim.ascent(dim.ascent() + 20);
56         ///
57         /// makes the code neither faster nor clearer
58         /// width
59         int wid;
60         /// ascent
61         int asc;
62         /// descent
63         int des;
64 };
65
66 inline
67 bool operator==(Dimension const & a, Dimension const & b)
68 {
69         return a.wid == b.wid && a.asc == b.asc && a.des ==b.des ;
70 }
71
72
73 } // namespace lyx
74
75 #endif