]> git.lyx.org Git - lyx.git/blob - src/mathed/button_inset.C
First shot at inset-unification mathed & rest of the world
[lyx.git] / src / mathed / button_inset.C
1
2 #include "button_inset.h"
3 #include "math_support.h"
4 #include "frontends/Painter.h"
5
6
7 ButtonInset::ButtonInset()
8         : MathNestInset(2)
9 {}
10
11
12 void ButtonInset::metrics(MathMetricsInfo & mi) const
13 {
14         MathFontSetChanger dummy(mi.base, "textnormal");
15         if (editing()) {
16                 MathNestInset::metrics(mi);
17                 width_   = xcell(0).width() + xcell(1).width() + 4;
18                 ascent_  = max(xcell(0).ascent(), xcell(1).ascent());
19                 descent_ = max(xcell(0).descent(), xcell(1).descent());
20         } else {
21                 string s = screenLabel();
22                 mathed_string_dim(mi.base.font,
23                                  s, ascent_, descent_, width_);
24                 width_ += 10;
25         }
26 }
27
28
29 void ButtonInset::draw(MathPainterInfo & pi, int x, int y) const
30 {
31         MathFontSetChanger dummy(pi.base, "textnormal");
32         if (editing()) {
33                 xcell(0).draw(pi, x, y);
34                 xcell(1).draw(pi, x + xcell(0).width() + 2, y);
35                 mathed_draw_framebox(pi, x, y, this);
36         } else {
37                 pi.pain.buttonText(x + 2, y, screenLabel(),
38                         pi.base.font);
39         }
40 }
41