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