#include "render_button.h"
-#include "BufferView.h"
#include "LColor.h"
#include "metricsinfo.h"
-#include "frontends/font_metrics.h"
-#include "frontends/LyXView.h"
+#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
+
+namespace lyx {
+
using std::string;
+using std::auto_ptr;
RenderButton::RenderButton()
{}
-RenderBase * RenderButton::clone() const
+auto_ptr<RenderBase> RenderButton::clone(InsetBase const *) const
{
- return new RenderButton(*this);
+ return auto_ptr<RenderBase>(new RenderButton(*this));
}
-void RenderButton::update(string const & text, bool editable)
+void RenderButton::update(docstring const & text, bool editable)
{
text_ = text;
editable_ = editable;
}
-void RenderButton::metrics(MetricsInfo &, Dimension & dim) const
+bool RenderButton::metrics(MetricsInfo &, Dimension & dim) const
{
LyXFont font(LyXFont::ALL_SANE);
font.decSize();
-
+ frontend::FontMetrics const & fm =
+ theFontMetrics(font);
+
if (editable_)
- font_metrics::buttonText(text_, font, dim.wid, dim.asc, dim.des);
+ fm.buttonText(text_, dim.wid, dim.asc, dim.des);
else
- font_metrics::rectText(text_, font, dim.wid, dim.asc, dim.des);
+ fm.rectText(text_, dim.wid, dim.asc, dim.des);
dim.wid += 4;
+ if (dim_ == dim)
+ return false;
+ dim_ = dim;
+ return true;
}
void RenderButton::draw(PainterInfo & pi, int x, int y) const
{
- BOOST_ASSERT(pi.base.bv);
- view_ = pi.base.bv->owner()->view();
-
// Draw it as a box with the LaTeX text
LyXFont font(LyXFont::ALL_SANE);
font.setColor(LColor::command);
font.decSize();
if (editable_) {
- pi.pain.buttonText(x + 2, y, text_, font);
+ pi.pain.buttonText(x + 2, y, text_, font, renderState());
} else {
pi.pain.rectText(x + 2, y, text_, font,
LColor::commandbg, LColor::commandframe);
}
}
+
+
+} // namespace lyx