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