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 InsetButton::InsetButton()
30 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
32 LyXFont font(LyXFont::ALL_SANE);
35 int width, ascent, descent;
36 string s = getScreenLabel();
39 bv->painter().buttonText(0, 0, s, font,
40 false, width, ascent, descent);
42 bv->painter().rectText(0, 0, s, font,
43 LColor::commandbg, LColor::commandframe,
44 false, width, ascent, descent);
50 int InsetButton::descent(BufferView * bv, LyXFont const &) const
52 LyXFont font(LyXFont::ALL_SANE);
55 int width, ascent, descent;
56 string s = getScreenLabel();
59 bv->painter().buttonText(0, 0, s, font,
60 false, width, ascent, descent);
62 bv->painter().rectText(0, 0, s, font,
63 LColor::commandbg, LColor::commandframe,
64 false, width, ascent, descent);
70 int InsetButton::width(BufferView * bv, LyXFont const &) const
72 LyXFont font(LyXFont::ALL_SANE);
75 int width, ascent, descent;
76 string s = getScreenLabel();
79 bv->painter().buttonText(0, 0, s, font,
80 false, width, ascent, descent);
82 bv->painter().rectText(0, 0, s, font,
83 LColor::commandbg, LColor::commandframe,
84 false, width, ascent, descent);
90 void InsetButton::draw(BufferView * bv, LyXFont const &,
91 int baseline, float & x, bool) const
93 Painter & pain = bv->painter();
94 // Draw it as a box with the LaTeX text
95 LyXFont font(LyXFont::ALL_SANE);
96 font.setColor(LColor::command).decSize();
99 string s = getScreenLabel();
102 pain.buttonText(int(x)+2, baseline, s, font, true, width);
104 pain.rectText(int(x)+2, baseline, s, font,
105 LColor::commandbg, LColor::commandframe,