1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 2000-2001 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
17 #include "insetbutton.h"
19 #include "BufferView.h"
21 #include "support/LAssert.h"
29 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
33 LyXFont font(LyXFont::ALL_SANE);
39 string const s = getScreenLabel(bv->buffer());
42 lyxfont::buttonText(s, font, width, ascent, descent);
44 lyxfont::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 lyxfont::buttonText(s, font, width, ascent, descent);
66 lyxfont::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 lyxfont::buttonText(s, font, width, ascent, descent);
88 lyxfont::rectText(s, font, width, ascent, descent);
95 void InsetButton::draw(BufferView * bv, LyXFont const &,
96 int baseline, float & x, bool) const
100 Painter & pain = bv->painter();
101 // Draw it as a box with the LaTeX text
102 LyXFont font(LyXFont::ALL_SANE);
103 font.setColor(LColor::command).decSize();
105 string const s = getScreenLabel(bv->buffer());
108 pain.buttonText(int(x) + 2, baseline, s, font);
110 pain.rectText(int(x) + 2, baseline, s, font,
111 LColor::commandbg, LColor::commandframe);
114 x += width(bv, font);