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 #pragma implementation
19 #include "insetbutton.h"
21 #include "BufferView.h"
22 #include "frontends/Painter.h"
23 #include "support/LAssert.h"
25 #include "frontends/font_metrics.h"
31 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
35 LyXFont font(LyXFont::ALL_SANE);
41 string const s = getScreenLabel(bv->buffer());
44 font_metrics::buttonText(s, font, width, ascent, descent);
46 font_metrics::rectText(s, font, width, ascent, descent);
53 int InsetButton::descent(BufferView * bv, LyXFont const &) const
57 LyXFont font(LyXFont::ALL_SANE);
63 string const s = getScreenLabel(bv->buffer());
66 font_metrics::buttonText(s, font, width, ascent, descent);
68 font_metrics::rectText(s, font, width, ascent, descent);
75 int InsetButton::width(BufferView * bv, LyXFont const &) const
79 LyXFont font(LyXFont::ALL_SANE);
85 string const s = getScreenLabel(bv->buffer());
88 font_metrics::buttonText(s, font, width, ascent, descent);
90 font_metrics::rectText(s, font, width, ascent, descent);
97 void InsetButton::draw(BufferView * bv, LyXFont const &,
98 int baseline, float & x, bool) const
102 Painter & pain = bv->painter();
103 // Draw it as a box with the LaTeX text
104 LyXFont font(LyXFont::ALL_SANE);
105 font.setColor(LColor::command).decSize();
107 string const s = getScreenLabel(bv->buffer());
110 pain.buttonText(int(x) + 2, baseline, s, font);
112 pain.rectText(int(x) + 2, baseline, s, font,
113 LColor::commandbg, LColor::commandframe);
116 x += width(bv, font);