]> git.lyx.org Git - lyx.git/blob - src/mathed/button_inset.C
replace (ascent, descent, width) triples by a structure 'dimension'
[lyx.git] / src / mathed / button_inset.C
1 #include <config.h>
2
3 #include "button_inset.h"
4 #include "math_support.h"
5 #include "frontends/Painter.h"
6
7 #include <algorithm>
8
9 using std::max;
10
11
12 ButtonInset::ButtonInset()
13         : MathNestInset(2)
14 {}
15
16
17 void ButtonInset::metrics(MathMetricsInfo & mi) const
18 {
19         MathFontSetChanger dummy(mi.base, "textnormal");
20         if (editing()) {
21                 MathNestInset::metrics(mi);
22                 dim_.w = xcell(0).width() + xcell(1).width() + 4;
23                 dim_.a = max(xcell(0).ascent(), xcell(1).ascent());
24                 dim_.d = max(xcell(0).descent(), xcell(1).descent());
25         } else {
26                 mathed_string_dim(mi.base.font, screenLabel(), dim_);
27                 dim_.w += 10;
28         }
29 }
30
31
32 void ButtonInset::draw(MathPainterInfo & pi, int x, int y) const
33 {
34         MathFontSetChanger dummy(pi.base, "textnormal");
35         if (editing()) {
36                 xcell(0).draw(pi, x, y);
37                 xcell(1).draw(pi, x + xcell(0).width() + 2, y);
38                 mathed_draw_framebox(pi, x, y, this);
39         } else {
40                 pi.pain.buttonText(x + 2, y, screenLabel(),
41                         pi.base.font);
42         }
43 }