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());
43 bv->painter().buttonText(0, 0, s, font,
44 false, width, ascent, descent);
46 bv->painter().rectText(0, 0, s, font,
47 LColor::commandbg, LColor::commandframe,
48 false, width, ascent, descent);
52 lyxfont::buttonText(s, font, width, ascent, descent);
54 lyxfont::rectText(s, font, width, ascent, descent);
61 int InsetButton::descent(BufferView * bv, LyXFont const &) const
65 LyXFont font(LyXFont::ALL_SANE);
71 string const s = getScreenLabel(bv->buffer());
75 bv->painter().buttonText(0, 0, s, font,
76 false, width, ascent, descent);
78 bv->painter().rectText(0, 0, s, font,
79 LColor::commandbg, LColor::commandframe,
80 false, width, ascent, descent);
84 lyxfont::buttonText(s, font, width, ascent, descent);
86 lyxfont::rectText(s, font, width, ascent, descent);
93 int InsetButton::width(BufferView * bv, LyXFont const &) const
97 LyXFont font(LyXFont::ALL_SANE);
103 string const s = getScreenLabel(bv->buffer());
107 bv->painter().buttonText(0, 0, s, font,
108 false, width, ascent, descent);
110 bv->painter().rectText(0, 0, s, font,
111 LColor::commandbg, LColor::commandframe,
112 false, width, ascent, descent);
116 lyxfont::buttonText(s, font, width, ascent, descent);
118 lyxfont::rectText(s, font, width, ascent, descent);
125 void InsetButton::draw(BufferView * bv, LyXFont const &,
126 int baseline, float & x, bool) const
130 Painter & pain = bv->painter();
131 // Draw it as a box with the LaTeX text
132 LyXFont font(LyXFont::ALL_SANE);
133 font.setColor(LColor::command).decSize();
135 string const s = getScreenLabel(bv->buffer());
140 pain.buttonText(int(x) + 2, baseline, s, font, true, width);
142 pain.rectText(int(x) + 2, baseline, s, font,
143 LColor::commandbg, LColor::commandframe,
148 pain.buttonText(int(x) + 2, baseline, s, font);
150 pain.rectText(int(x) + 2, baseline, s, font,
151 LColor::commandbg, LColor::commandframe);
158 x += width(bv, font);