]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetbutton.C
Clean up InsetGraphics::Cache and rename as GraphicsInset.
[lyx.git] / src / insets / insetbutton.C
index 8f46a7557427258f7b269516d9acea6e7b439598..796d46d9a8dbf952c1c97274c7a7b7d3902459df 100644 (file)
 #include "frontends/Painter.h"
 #include "support/LAssert.h"
 #include "lyxfont.h"
+#include "metricsinfo.h"
 #include "frontends/font_metrics.h"
 
 using std::ostream;
 using std::endl;
 
 
-void InsetButton::dimension(BufferView * bv, LyXFont const &,
-       Dimension & dim) const
+void InsetButton::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       lyx::Assert(bv);
+       lyx::Assert(mi.base.bv);
 
        LyXFont font(LyXFont::ALL_SANE);
        font.decSize();
 
-       string const s = getScreenLabel(bv->buffer());
+       string const s = getScreenLabel(mi.base.bv->buffer());
 
-       if (editable()) 
-               font_metrics::buttonText(s, font, dim.w, dim.a, dim.d);
-       else 
-               font_metrics::rectText(s, font, dim.w, dim.a, dim.d);
-       
-       dim.w += 4;
+       if (editable())
+               font_metrics::buttonText(s, font, dim.wid, dim.asc, dim.des);
+       else
+               font_metrics::rectText(s, font, dim.wid, dim.asc, dim.des);
+
+       dim.wid += 4;
 }
 
 
-void InsetButton::draw(BufferView * bv, LyXFont const &,
-                       int baseline, float & x) const
+void InsetButton::draw(PainterInfo & pi, int x, int y) const
 {
-       lyx::Assert(bv);
-       cache(bv);
+       lyx::Assert(pi.base.bv);
+       cache(pi.base.bv);
 
-       Painter & pain = bv->painter();
        // Draw it as a box with the LaTeX text
        LyXFont font(LyXFont::ALL_SANE);
        font.setColor(LColor::command).decSize();
 
-       string const s = getScreenLabel(bv->buffer());
+       string const s = getScreenLabel(pi.base.bv->buffer());
 
        if (editable()) {
-               pain.buttonText(int(x) + 2, baseline, s, font);
+               pi.pain.buttonText(x + 2, y, s, font);
        } else {
-               pain.rectText(int(x) + 2, baseline, s, font,
+               pi.pain.rectText(x + 2, y, s, font,
                              LColor::commandbg, LColor::commandframe);
        }
-
-       x += width(bv, font);
 }