]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetVSpace.cpp
This should be the last of the commits refactoring the InsetLayout code.
[lyx.git] / src / insets / InsetVSpace.cpp
index f45801c7b6571b335471e79528cce715a85b3f10..24cfe3ebcf14869a9e8ddf1576e211d28143b992 100644 (file)
 
 #include "Buffer.h"
 #include "Cursor.h"
+#include "Dimension.h"
 #include "DispatchResult.h"
 #include "FuncRequest.h"
-#include "gettext.h"
-#include "Color.h"
+#include "support/gettext.h"
 #include "Lexer.h"
 #include "Text.h"
 #include "MetricsInfo.h"
 
 #include <sstream>
 
+using namespace std;
 
 namespace lyx {
 
-using std::istringstream;
-using std::ostream;
-using std::ostringstream;
-using std::string;
-using std::max;
-
-
 namespace {
 
 int const ADD_TO_VSPACE_WIDTH = 5;
@@ -124,7 +118,7 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
        if (space_.length().len().value() >= 0.0)
                height = max(height, space_.inPixels(*mi.base.bv));
 
-       Font font;
+       FontInfo font;
        font.decSize();
        font.decSize();
 
@@ -138,16 +132,17 @@ void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
        dim.asc = height / 2 + (a - d) / 2; // align cursor with the
        dim.des = height - dim.asc;         // label text
        dim.wid = ADD_TO_VSPACE_WIDTH + 2 * arrow_size + 5 + w;
-       dim_ = dim;
+       // Cache the inset dimension. 
+       setDimCache(mi, dim);
 }
 
 
 void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
 {
+       Dimension const dim = dimension(*pi.base.bv);
        x += ADD_TO_VSPACE_WIDTH;
-
-       int const start = y - dim_.asc;
-       int const end   = y + dim_.des;
+       int const start = y - dim.asc;
+       int const end   = y + dim.des;
 
        // y-values for top arrow
        int ty1, ty2;
@@ -175,8 +170,8 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
        int a = 0;
        int d = 0;
 
-       Font font;
-       font.setColor(Color::added_space);
+       FontInfo font;
+       font.setColor(Color_added_space);
        font.decSize();
        font.decSize();
        docstring const lab = label();
@@ -184,18 +179,18 @@ void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
 
        pi.pain.rectText(x + 2 * arrow_size + 5,
                         start + (end - start) / 2 + (a - d) / 2,
-                        lab, font, Color::none, Color::none);
+                        lab, font, Color_none, Color_none);
 
        // top arrow
-       pi.pain.line(x, ty1, midx, ty2, Color::added_space);
-       pi.pain.line(midx, ty2, rightx, ty1, Color::added_space);
+       pi.pain.line(x, ty1, midx, ty2, Color_added_space);
+       pi.pain.line(midx, ty2, rightx, ty1, Color_added_space);
 
        // bottom arrow
-       pi.pain.line(x, by1, midx, by2, Color::added_space);
-       pi.pain.line(midx, by2, rightx, by1, Color::added_space);
+       pi.pain.line(x, by1, midx, by2, Color_added_space);
+       pi.pain.line(midx, by2, rightx, by1, Color_added_space);
 
        // joining line
-       pi.pain.line(midx, ty2, midx, by2, Color::added_space);
+       pi.pain.line(midx, ty2, midx, by2, Color_added_space);
 }