]> git.lyx.org Git - lyx.git/blob - src/mathed/button_inset.C
fix the <...> delimiters
[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                 width_   = xcell(0).width() + xcell(1).width() + 4;
23                 ascent_  = max(xcell(0).ascent(), xcell(1).ascent());
24                 descent_ = max(xcell(0).descent(), xcell(1).descent());
25         } else {
26                 string s = screenLabel();
27                 mathed_string_dim(mi.base.font,
28                                  s, ascent_, descent_, width_);
29                 width_ += 10;
30         }
31 }
32
33
34 void ButtonInset::draw(MathPainterInfo & pi, int x, int y) const
35 {
36         MathFontSetChanger dummy(pi.base, "textnormal");
37         if (editing()) {
38                 xcell(0).draw(pi, x, y);
39                 xcell(1).draw(pi, x + xcell(0).width() + 2, y);
40                 mathed_draw_framebox(pi, x, y, this);
41         } else {
42                 pi.pain.buttonText(x + 2, y, screenLabel(),
43                         pi.base.font);
44         }
45 }