2 * \file render_button.C
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS.
13 #include "render_button.h"
16 #include "metricsinfo.h"
18 #include "frontends/Application.h"
19 #include "frontends/FontLoader.h"
20 #include "frontends/FontMetrics.h"
21 #include "frontends/Painter.h"
29 RenderButton::RenderButton()
34 auto_ptr<RenderBase> RenderButton::clone(InsetBase const *) const
36 return auto_ptr<RenderBase>(new RenderButton(*this));
40 void RenderButton::update(string const & text, bool editable)
47 void RenderButton::metrics(MetricsInfo &, Dimension & dim) const
49 LyXFont font(LyXFont::ALL_SANE);
51 lyx::frontend::FontMetrics const & fm =
52 theApp->fontLoader().metrics(font);
54 docstring dtext(text_.begin(), text_.end());
57 fm.buttonText(dtext, dim.wid, dim.asc, dim.des);
59 fm.rectText(dtext, dim.wid, dim.asc, dim.des);
65 void RenderButton::draw(PainterInfo & pi, int x, int y) const
67 // Draw it as a box with the LaTeX text
68 LyXFont font(LyXFont::ALL_SANE);
69 font.setColor(LColor::command);
72 docstring dtext(text_.begin(), text_.end());
75 pi.pain.buttonText(x + 2, y, dtext, font);
77 pi.pain.rectText(x + 2, y, dtext, font,
78 LColor::commandbg, LColor::commandframe);