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"
28 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
32 LyXFont font(LyXFont::ALL_SANE);
38 string const s = getScreenLabel();
41 bv->painter().buttonText(0, 0, s, font,
42 false, width, ascent, descent);
44 bv->painter().rectText(0, 0, s, font,
45 LColor::commandbg, LColor::commandframe,
46 false, width, ascent, descent);
52 int InsetButton::descent(BufferView * bv, LyXFont const &) const
56 LyXFont font(LyXFont::ALL_SANE);
62 string const s = getScreenLabel();
65 bv->painter().buttonText(0, 0, s, font,
66 false, width, ascent, descent);
68 bv->painter().rectText(0, 0, s, font,
69 LColor::commandbg, LColor::commandframe,
70 false, width, ascent, descent);
76 int InsetButton::width(BufferView * bv, LyXFont const &) const
80 LyXFont font(LyXFont::ALL_SANE);
86 string const s = getScreenLabel();
89 bv->painter().buttonText(0, 0, s, font,
90 false, width, ascent, descent);
92 bv->painter().rectText(0, 0, s, font,
93 LColor::commandbg, LColor::commandframe,
94 false, width, ascent, descent);
100 void InsetButton::draw(BufferView * bv, LyXFont const &,
101 int baseline, float & x, bool) const
105 Painter & pain = bv->painter();
106 // Draw it as a box with the LaTeX text
107 LyXFont font(LyXFont::ALL_SANE);
108 font.setColor(LColor::command).decSize();
111 string const s = getScreenLabel();
114 pain.buttonText(int(x) + 2, baseline, s, font, true, width);
116 pain.rectText(int(x) + 2, baseline, s, font,
117 LColor::commandbg, LColor::commandframe,