#include "LColor.h"
#include "metricsinfo.h"
-#include "frontends/font_metrics.h"
+#include "frontends/FontMetrics.h"
#include "frontends/Painter.h"
-using lyx::docstring;
+
+namespace lyx {
using std::string;
using std::auto_ptr;
}
-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();
-
- docstring dtext(text_.begin(), text_.end());
-
+ frontend::FontMetrics const & fm =
+ theFontMetrics(font);
+
if (editable_)
- font_metrics::buttonText(dtext, font, dim.wid, dim.asc, dim.des);
+ fm.buttonText(text_, dim.wid, dim.asc, dim.des);
else
- font_metrics::rectText(dtext, 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;
}
font.setColor(LColor::command);
font.decSize();
- docstring dtext(text_.begin(), text_.end());
-
if (editable_) {
- pi.pain.buttonText(x + 2, y, dtext, font);
+ pi.pain.buttonText(x + 2, y, text_, font, renderState());
} else {
- pi.pain.rectText(x + 2, y, dtext, font,
+ pi.pain.rectText(x + 2, y, text_, font,
LColor::commandbg, LColor::commandframe);
}
}
+
+
+} // namespace lyx