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