3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Asger Alstrup Nielsen
8 * \author Lars Gullik Bjønnes
10 * Full author contact details are available in file CREDITS
16 #include "insetbutton.h"
18 #include "BufferView.h"
19 #include "frontends/Painter.h"
20 #include "support/LAssert.h"
22 #include "frontends/font_metrics.h"
28 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
32 LyXFont font(LyXFont::ALL_SANE);
38 string const s = getScreenLabel(bv->buffer());
41 font_metrics::buttonText(s, font, width, ascent, descent);
43 font_metrics::rectText(s, font, width, ascent, descent);
50 int InsetButton::descent(BufferView * bv, LyXFont const &) const
54 LyXFont font(LyXFont::ALL_SANE);
60 string const s = getScreenLabel(bv->buffer());
63 font_metrics::buttonText(s, font, width, ascent, descent);
65 font_metrics::rectText(s, font, width, ascent, descent);
72 int InsetButton::width(BufferView * bv, LyXFont const &) const
76 LyXFont font(LyXFont::ALL_SANE);
82 string const s = getScreenLabel(bv->buffer());
85 font_metrics::buttonText(s, font, width, ascent, descent);
87 font_metrics::rectText(s, font, width, ascent, descent);
94 void InsetButton::draw(BufferView * bv, LyXFont const &,
95 int baseline, float & x, bool) const
99 Painter & pain = bv->painter();
100 // Draw it as a box with the LaTeX text
101 LyXFont font(LyXFont::ALL_SANE);
102 font.setColor(LColor::command).decSize();
104 string const s = getScreenLabel(bv->buffer());
107 pain.buttonText(int(x) + 2, baseline, s, font);
109 pain.rectText(int(x) + 2, baseline, s, font,
110 LColor::commandbg, LColor::commandframe);
113 x += width(bv, font);