]> git.lyx.org Git - lyx.git/blob - src/dimension.h
rename the members of Dimension
[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() : 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 public:
44         /// these are intentionally public as things like
45         ///
46         ///   dim.asc += 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 wid;
55         /// ascent
56         int asc;
57         /// descent
58         int des;
59 };
60
61 #endif