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();
77 bv->painter().buttonText(0, 0, s, font,
78 false, width, ascent, descent);
80 bv->painter().rectText(0, 0, s, font,
81 LColor::commandbg, LColor::commandframe,
82 false, width, ascent, descent);
88 void InsetButton::draw(BufferView * bv, LyXFont const &,
89 int baseline, float & x, bool) const
91 Painter & pain = bv->painter();
92 // Draw it as a box with the LaTeX text
93 LyXFont font(LyXFont::ALL_SANE);
94 font.setColor(LColor::command).decSize();
97 string s = getScreenLabel();
100 pain.buttonText(int(x)+2, baseline, s, font, true, width);
102 pain.rectText(int(x)+2, baseline, s, font,
103 LColor::commandbg, LColor::commandframe,