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"
26 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
28 LyXFont font(LyXFont::ALL_SANE);
31 int width, ascent, descent;
32 string s = getScreenLabel();
35 bv->painter().buttonText(0, 0, s, font,
36 false, width, ascent, descent);
38 bv->painter().rectText(0, 0, s, font,
39 LColor::commandbg, LColor::commandframe,
40 false, width, ascent, descent);
46 int InsetButton::descent(BufferView * bv, LyXFont const &) const
48 LyXFont font(LyXFont::ALL_SANE);
51 int width, ascent, descent;
52 string s = getScreenLabel();
55 bv->painter().buttonText(0, 0, s, font,
56 false, width, ascent, descent);
58 bv->painter().rectText(0, 0, s, font,
59 LColor::commandbg, LColor::commandframe,
60 false, width, ascent, descent);
66 int InsetButton::width(BufferView * bv, LyXFont const &) const
68 LyXFont font(LyXFont::ALL_SANE);
71 int width, ascent, descent;
72 string s = getScreenLabel();
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);
86 void InsetButton::draw(BufferView * bv, LyXFont const &,
87 int baseline, float & x, bool) const
89 Painter & pain = bv->painter();
90 // Draw it as a box with the LaTeX text
91 LyXFont font(LyXFont::ALL_SANE);
92 font.setColor(LColor::command).decSize();
95 string s = getScreenLabel();
98 pain.buttonText(int(x)+2, baseline, s, font, true, width);
100 pain.rectText(int(x)+2, baseline, s, font,
101 LColor::commandbg, LColor::commandframe,