]> git.lyx.org Git - lyx.git/blob - src/mathed/button_inset.C
Make lyx2lyx output the new external inset format.
[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, Dimension & dim) const
20 {
21         FontSetChanger dummy(mi.base, "textnormal");
22         if (editing()) {
23                 MathNestInset::metrics(mi);
24                 dim_.wid = cell(0).width() + cell(1).width() + 4;
25                 dim_.asc = max(cell(0).ascent(), cell(1).ascent());
26                 dim_.des = max(cell(0).descent(), cell(1).descent());
27         } else {
28                 mathed_string_dim(mi.base.font, screenLabel(), dim_);
29                 dim_.wid += 10;
30         }
31         dim = dim_;
32 }
33
34
35 void ButtonInset::draw(PainterInfo & pi, int x, int y) const
36 {
37         FontSetChanger dummy(pi.base, "textnormal");
38         if (editing()) {
39                 cell(0).draw(pi, x, y);
40                 cell(1).draw(pi, x + cell(0).width() + 2, y);
41                 //if (mathcursor && mathcursor->isInside(p))
42                         pi.pain.rectangle(x, y - dim_.ascent(), dim_.width(), dim_.height(),
43                                 LColor::mathframe);
44         } else {
45                 pi.pain.buttonText(x + 2, y, screenLabel(), pi.base.font);
46         }
47 }