X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Frender_button.C;h=a20b378a90b40bfde461000483d1cd8b59705233;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=883b6244fe7bbbd4ae4fa4b7538973a0596757c2;hpb=00edcc582ff7cfe9cbbc8f7458ea29649bd642d9;p=lyx.git diff --git a/src/insets/render_button.C b/src/insets/render_button.C index 883b6244fe..a20b378a90 100644 --- a/src/insets/render_button.C +++ b/src/insets/render_button.C @@ -15,12 +15,11 @@ #include "LColor.h" #include "metricsinfo.h" -#include "frontends/Application.h" -#include "frontends/FontLoader.h" #include "frontends/FontMetrics.h" #include "frontends/Painter.h" -using lyx::docstring; + +namespace lyx { using std::string; using std::auto_ptr; @@ -37,28 +36,30 @@ auto_ptr RenderButton::clone(InsetBase const *) const } -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(); - lyx::frontend::FontMetrics const & fm = - theApp->fontLoader().metrics(font); + frontend::FontMetrics const & fm = + theFontMetrics(font); - docstring dtext(text_.begin(), text_.end()); - if (editable_) - fm.buttonText(dtext, dim.wid, dim.asc, dim.des); + fm.buttonText(text_, dim.wid, dim.asc, dim.des); else - fm.rectText(dtext, 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; } @@ -69,12 +70,13 @@ void RenderButton::draw(PainterInfo & pi, int x, int y) const 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