]> git.lyx.org Git - lyx.git/blobdiff - src/insets/Inset.cpp
Fix text frame drawing.
[lyx.git] / src / insets / Inset.cpp
index e1a8a4e975341ca856247c1a2f254e140975236b..033764b307f055b44b962cf6f0da6fefe664492a 100644 (file)
@@ -17,6 +17,7 @@
 #include "Inset.h"
 
 #include "Buffer.h"
+#include "BufferParams.h"
 #include "BufferView.h"
 #include "Color.h"
 #include "CoordCache.h"
@@ -29,6 +30,7 @@
 #include "FuncStatus.h"
 #include "gettext.h"
 #include "Text.h"
+#include "TextClass.h"
 #include "MetricsInfo.h"
 #include "MetricsInfo.h"
 
@@ -117,18 +119,10 @@ static TranslatorMap const build_translator()
 
 /// pretty arbitrary dimensions
 Inset::Inset()
-       : dim_(10, 10, 10), background_color_(Color::background)
+       : dim_(10, 10, 10)
 {}
 
 
-std::auto_ptr<Inset> Inset::clone() const
-{
-       std::auto_ptr<Inset> b = doClone();
-       BOOST_ASSERT(typeid(*b) == typeid(*this));
-       return b;
-}
-
-
 Inset::Code Inset::translate(std::string const & name)
 {
        static TranslatorMap const translator = build_translator();
@@ -280,6 +274,37 @@ void Inset::metricsMarkers2(Dimension & dim, int framesize) const
 }
 
 
+void Inset::drawMarkers(PainterInfo & pi, int x, int y) const
+{
+       Color::color pen_color = mouseHovered() || editing(pi.base.bv)?
+               Color::mathframe : Color::mathcorners;
+
+       int const t = x + width() - 1;
+       int const d = y + descent();
+       pi.pain.line(x, d - 3, x, d, pen_color);
+       pi.pain.line(t, d - 3, t, d, pen_color);
+       pi.pain.line(x, d, x + 3, d, pen_color);
+       pi.pain.line(t - 3, d, t, d, pen_color);
+       setPosCache(pi, x, y);
+}
+
+
+void Inset::drawMarkers2(PainterInfo & pi, int x, int y) const
+{
+       Color::color pen_color = mouseHovered() || editing(pi.base.bv)?
+               Color::mathframe : Color::mathcorners;
+
+       drawMarkers(pi, x, y);
+       int const t = x + width() - 1;
+       int const a = y - ascent();
+       pi.pain.line(x, a + 3, x, a, pen_color);
+       pi.pain.line(t, a + 3, t, a, pen_color);
+       pi.pain.line(x, a, x + 3, a, pen_color);
+       pi.pain.line(t - 3, a, t, a, pen_color);
+       setPosCache(pi, x, y);
+}
+
+
 bool Inset::editing(BufferView * bv) const
 {
        return bv->cursor().isInside(this);
@@ -313,22 +338,22 @@ bool Inset::covers(BufferView const & bv, int x, int y) const
 }
 
 
-void Inset::dump() const
+InsetLayout const & Inset::getLayout(BufferParams const & bp) const
 {
-       Buffer buf("foo", 1);
-       write(buf, lyxerr);
+       return bp.getTextClass().insetlayout(name());  
 }
 
 
-void Inset::setBackgroundColor(Color_color color)
+void Inset::dump() const
 {
-       background_color_ = color;
+       Buffer buf("foo", 1);
+       write(buf, lyxerr);
 }
 
 
 Color_color Inset::backgroundColor() const
 {
-       return Color::color(background_color_);
+       return Color::background;
 }