1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 2000 The LyX Team.
9 * ====================================================== */
14 #pragma implementation
17 #include "insetbutton.h"
19 #include "BufferView.h"
21 #include "support/LAssert.h"
27 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
31 LyXFont font(LyXFont::ALL_SANE);
37 string const s = getScreenLabel();
40 bv->painter().buttonText(0, 0, s, font,
41 false, width, ascent, descent);
43 bv->painter().rectText(0, 0, s, font,
44 LColor::commandbg, LColor::commandframe,
45 false, width, ascent, descent);
51 int InsetButton::descent(BufferView * bv, LyXFont const &) const
55 LyXFont font(LyXFont::ALL_SANE);
61 string const s = getScreenLabel();
64 bv->painter().buttonText(0, 0, s, font,
65 false, width, ascent, descent);
67 bv->painter().rectText(0, 0, s, font,
68 LColor::commandbg, LColor::commandframe,
69 false, width, ascent, descent);
75 int InsetButton::width(BufferView * bv, LyXFont const &) const
79 LyXFont font(LyXFont::ALL_SANE);
85 string const s = getScreenLabel();
88 bv->painter().buttonText(0, 0, s, font,
89 false, width, ascent, descent);
91 bv->painter().rectText(0, 0, s, font,
92 LColor::commandbg, LColor::commandframe,
93 false, width, ascent, descent);
99 void InsetButton::draw(BufferView * bv, LyXFont const &,
100 int baseline, float & x, bool) const
104 Painter & pain = bv->painter();
105 // Draw it as a box with the LaTeX text
106 LyXFont font(LyXFont::ALL_SANE);
107 font.setColor(LColor::command).decSize();
110 string const s = getScreenLabel();
113 pain.buttonText(int(x) + 2, baseline, s, font, true, width);
115 pain.rectText(int(x) + 2, baseline, s, font,
116 LColor::commandbg, LColor::commandframe,