]> git.lyx.org Git - lyx.git/blob - src/dimension.h
Change the color of the background widget to red.
[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 class LyXFont;
17
18 /// Simple wrapper around three ints
19 struct Dimension {
20 public:
21         /// constructor
22         Dimension() : wid(0), asc(0), des(0) {}
23         /// initialize data
24         Dimension(int w, int a, int d) : wid(w), asc(a), des(d) {}
25
26         /// glue horizontally
27         void operator+=(Dimension const & dim);
28         /// set to empty box
29         void clear() { wid = asc = des = 0; }
30         /// set to empty box suitble for given font
31         void clear(LyXFont const & font);
32         /// get height
33         int height() const { return asc + des; }
34         /// get ascent
35         int ascent() const { return asc; }
36         /// get descent
37         int descent() const { return des; }
38         /// get width
39         int width() const { return wid; }
40
41         /// add space for a frame
42         //void addFrame(int frame) const;
43         /// add space for bottom part of a frame
44         //void addFrameBottom(int frame) const;
45
46 public:
47         /// these are intentionally public as things like
48         ///
49         ///   dim.asc += 20;
50         ///
51         /// are used all over the place and "hiding" those behind
52         ///
53         ///   dim.ascent(dim.ascent() + 20);
54         ///
55         /// makes the code neither faster nor clearer
56         /// width
57         int wid;
58         /// ascent
59         int asc;
60         /// descent
61         int des;
62 };
63
64 #endif