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/LyXView.h"
20 #include "frontends/Painter.h"
21 #include "support/LAssert.h"
23 #include "frontends/font_metrics.h"
29 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
33 LyXFont font(LyXFont::ALL_SANE);
39 string const s = getScreenLabel(bv->buffer());
42 font_metrics::buttonText(s, font, width, ascent, descent);
44 font_metrics::rectText(s, font, width, ascent, descent);
51 int InsetButton::descent(BufferView * bv, LyXFont const &) const
55 LyXFont font(LyXFont::ALL_SANE);
61 string const s = getScreenLabel(bv->buffer());
64 font_metrics::buttonText(s, font, width, ascent, descent);
66 font_metrics::rectText(s, font, width, ascent, descent);
73 int InsetButton::width(BufferView * bv, LyXFont const &) const
77 LyXFont font(LyXFont::ALL_SANE);
83 string const s = getScreenLabel(bv->buffer());
86 font_metrics::buttonText(s, font, width, ascent, descent);
88 font_metrics::rectText(s, font, width, ascent, descent);
95 void InsetButton::draw(BufferView * bv, LyXFont const &,
96 int baseline, float & x, bool) const
101 Painter & pain = bv->painter();
102 // Draw it as a box with the LaTeX text
103 LyXFont font(LyXFont::ALL_SANE);
104 font.setColor(LColor::command).decSize();
106 string const s = getScreenLabel(bv->buffer());
109 pain.buttonText(int(x) + 2, baseline, s, font);
111 pain.rectText(int(x) + 2, baseline, s, font,
112 LColor::commandbg, LColor::commandframe);
115 x += width(bv, font);
119 void InsetButton::cache(BufferView * bv) const
121 view_ = bv->owner()->view();
125 BufferView * InsetButton::view() const