]> git.lyx.org Git - lyx.git/blob - src/dimension.h
The "I want this in now" patch.
[lyx.git] / src / dimension.h
1 // -*- C++ -*-
2
3 /**
4  *  \file dimension.h
5  *
6  *  This file is part of LyX, the document processor.
7  *  Licence details can be found in the file COPYING.
8  *
9  *  \author André Pönitz
10  *
11  *  Full author contact details are available in file CREDITS.
12  */
13
14 #ifndef DIMENSION_H
15 #define DIMENSION_H
16
17
18 class LyXFont;
19
20 /// Simple wrapper around three ints
21 struct Dimension {
22 public:
23         /// constructor
24         Dimension() : w(0), a(0), d(0) {}
25         /// initialize data
26         Dimension(int ww, int aa, int dd) : w(ww), a(aa), d(dd) {}
27
28         /// glue horizontally
29         void operator+=(Dimension const & dim);
30         /// set to empty box
31         void clear() { w = a = d = 0; }
32         /// set to empty box suitble for given font
33         void clear(LyXFont const & font);
34         /// get height
35         int height() const { return a + d; }
36         /// get ascent
37         int ascent() const { return a; }
38         /// get descent
39         int descent() const { return d; }
40         /// get width
41         int width() const { return w; }
42
43 public:
44         /// these are intentionally public as things like
45         ///
46         ///   dim.a += 20; 
47         ///
48         /// are used all over the place and "hiding" those behind
49         ///
50         ///   dim.ascent(dim.ascent() + 20);
51         ///
52         /// makes the code neither faster nor clearer
53         /// width
54         int w;
55         /// ascent
56         int a;
57         /// descent
58         int d;
59 };
60
61 #endif