2 * \file RenderButton.cpp
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 "RenderButton.h"
15 #include "MetricsInfo.h"
17 #include "frontends/FontMetrics.h"
18 #include "frontends/Painter.h"
24 RenderButton::RenderButton()
25 : editable_(false), broken_(false), inherit_font_(false)
29 RenderBase * RenderButton::clone(Inset const *) const
31 return new RenderButton(*this);
35 void RenderButton::update(docstring const & text, bool editable,
36 bool inherit, bool broken)
40 inherit_font_ = inherit;
45 void RenderButton::metrics(MetricsInfo & mi, Dimension & dim) const
47 FontInfo font = inherit_font_ ? mi.base.font : sane_font;
49 frontend::FontMetrics const & fm = theFontMetrics(font);
51 fm.buttonText(text_, Inset::textOffset(mi.base.bv), dim.wid, dim.asc, dim.des);
57 void RenderButton::draw(PainterInfo & pi, int x, int y) const
59 // Draw it as a box with the LaTeX text
60 FontInfo font = inherit_font_ ? pi.base.font : sane_font;
61 font.setColor(Color_command);
65 font.setColor(Color_command_broken);
66 pi.pain.buttonText(x, y, text_, font,
67 renderState() ? Color_buttonhoverbg_broken : Color_buttonbg_broken,
68 Color_buttonframe_broken, Inset::textOffset(pi.base.bv));
69 } else if (editable_) {
70 pi.pain.buttonText(x, y, text_, font,
71 renderState() ? Color_buttonhoverbg : Color_buttonbg,
72 Color_buttonframe, Inset::textOffset(pi.base.bv));
74 pi.pain.buttonText(x, y, text_, font,
75 Color_commandbg, Color_commandframe,
76 Inset::textOffset(pi.base.bv));