]> git.lyx.org Git - lyx.git/blobdiff - src/insets/render_button.C
* src/LyXAction.C: mark goto-clear-bookmark as working without buffer
[lyx.git] / src / insets / render_button.C
index 1537ecf14ccd46491997bf78274eae6f5cbb87b6..a20b378a90b40bfde461000483d1cd8b59705233 100644 (file)
 #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;
@@ -35,26 +36,30 @@ auto_ptr<RenderBase> 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();
-
-        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;
 }
 
 
@@ -65,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