]> git.lyx.org Git - lyx.git/blobdiff - src/insets/inseterror.C
Clean up InsetGraphics::Cache and rename as GraphicsInset.
[lyx.git] / src / insets / inseterror.C
index a0dd7e9a64fde0de457bab2dc8b19c9905a03a1f..d4dc0ab2f8eeacca4baf224148d742fd1dfdb11b 100644 (file)
 #include "inseterror.h"
 
 #include "BufferView.h"
-#include "dimension.h"
 #include "funcrequest.h"
 #include "gettext.h"
 #include "lyxfont.h"
+#include "metricsinfo.h"
 
 #include "frontends/Dialogs.h"
 #include "frontends/font_metrics.h"
@@ -60,41 +60,33 @@ dispatch_result InsetError::localDispatch(FuncRequest const & cmd)
 }
 
 
-void InsetError::dimension(BufferView *, LyXFont const & font,
-       Dimension & dim) const
+void InsetError::metrics(MetricsInfo & mi, Dimension & dim) const
 {
        LyXFont efont;
-       efont.setSize(font.size()).decSize();
-       dim.asc = font_metrics::maxAscent(efont) + 1;
-       dim.des = font_metrics::maxDescent(efont) + 1;
-       dim.wid = 6 + font_metrics::width(_("Error"), efont);
+       efont.setSize(mi.base.font.size()).decSize();
+       dim_.asc = font_metrics::maxAscent(efont) + 1;
+       dim_.des = font_metrics::maxDescent(efont) + 1;
+       dim_.wid = 6 + font_metrics::width(_("Error"), efont);
+       dim = dim_;
 }
 
 
-void InsetError::draw(BufferView * bv, LyXFont const & font,
-                     int baseline, float & x) const
+void InsetError::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();
        LyXFont efont;
-       efont.setSize(font.size()).decSize();
+       efont.setSize(pi.base.font.size()).decSize();
        efont.setColor(LColor::error);
 
        // Draw as "Error" in a framed box
        x += 1;
-       pain.fillRectangle(int(x), baseline - ascent(bv, font) + 1,
-                         width(bv, font) - 2,
-                         ascent(bv, font) + descent(bv, font) - 2,
-                          LColor::insetbg);
-       pain.rectangle(int(x), baseline - ascent(bv, font) + 1,
-                      width(bv, font) - 2,
-                      ascent(bv, font) + descent(bv, font) - 2,
-                      LColor::error);
-       pain.text(int(x + 2), baseline, _("Error"), efont);
-
-       x +=  width(bv, font) - 1;
+       pi.pain.fillRectangle(x, y - dim_.asc + 1,
+             dim_.wid - 2, dim_.asc + dim_.des - 2, LColor::insetbg);
+       pi.pain.rectangle(x, y - dim_.asc + 1,
+             dim_.wid - 2, dim_.asc + dim_.des - 2, LColor::error);
+       pi.pain.text(x + 2, y, _("Error"), efont);
 }