#include "Inset.h"
#include "Buffer.h"
+#include "BufferParams.h"
#include "BufferView.h"
#include "Color.h"
#include "CoordCache.h"
#include "Cursor.h"
#include "debug.h"
-#include "debug.h"
#include "Dimension.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
#include "FuncStatus.h"
#include "gettext.h"
#include "Text.h"
+#include "TextClass.h"
#include "MetricsInfo.h"
#include "MetricsInfo.h"
#include "frontends/Painter.h"
+#include "support/convert.h"
+
#include <boost/current_function.hpp>
#include <map>
InsetName("external", Inset::EXTERNAL_CODE),
InsetName("caption", Inset::CAPTION_CODE),
InsetName("mathmacro", Inset::MATHMACRO_CODE),
- InsetName("cite", Inset::CITE_CODE),
- InsetName("float_list", Inset::FLOAT_LIST_CODE),
+ InsetName("citation", Inset::CITE_CODE),
+ InsetName("floatlist", Inset::FLOAT_LIST_CODE),
InsetName("index_print", Inset::INDEX_PRINT_CODE),
InsetName("nomencl_print", Inset::NOMENCL_PRINT_CODE),
InsetName("optarg", Inset::OPTARG_CODE),
InsetName("line", Inset::LINE_CODE),
InsetName("branch", Inset::BRANCH_CODE),
InsetName("box", Inset::BOX_CODE),
- InsetName("charstyle", Inset::CHARSTYLE_CODE),
+ InsetName("flex", Inset::FLEX_CODE),
InsetName("vspace", Inset::VSPACE_CODE),
InsetName("mathmacroarg", Inset::MATHMACROARG_CODE),
InsetName("listings", Inset::LISTINGS_CODE),
}
-/// pretty arbitrary dimensions
Inset::Inset()
- : dim_(10, 10, 10)
{}
-std::auto_ptr<Inset> Inset::clone() const
+Dimension const Inset::dimension(BufferView const & bv) const
{
- std::auto_ptr<Inset> b = doClone();
- BOOST_ASSERT(typeid(*b) == typeid(*this));
- return b;
+ return bv.coordCache().getInsets().dim(this);
}
Color::color pen_color = mouseHovered() || editing(pi.base.bv)?
Color::mathframe : Color::mathcorners;
- int const t = x + width() - 1;
- int const d = y + descent();
+ Dimension const dim = dimension(*pi.base.bv);
+
+ int const t = x + dim.width() - 1;
+ int const d = y + dim.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);
Color::mathframe : Color::mathcorners;
drawMarkers(pi, x, y);
- int const t = x + width() - 1;
- int const a = y - ascent();
+ Dimension const dim = dimension(*pi.base.bv);
+ int const t = x + dim.width() - 1;
+ int const a = y - dim.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);
bool Inset::covers(BufferView const & bv, int x, int y) const
{
- //lyxerr << "Inset::covers, x: " << x << " y: " << y
- // << " xo: " << xo(bv) << " yo: " << yo()
- // << " x1: " << xo(bv) << " x2: " << xo() + width()
- // << " y1: " << yo(bv) - ascent() << " y2: " << yo() + descent()
- // << std::endl;
- return bv.coordCache().getInsets().has(this)
- && x >= xo(bv)
- && x <= xo(bv) + width()
- && y >= yo(bv) - ascent()
- && y <= yo(bv) + descent();
+ return bv.coordCache().getInsets().covers(this, x, y);
+}
+
+
+InsetLayout const & Inset::getLayout(BufferParams const & bp) const
+{
+ return bp.getTextClass().insetlayout(name());
}
}
+void Inset::setDimCache(MetricsInfo const & mi, Dimension const & dim) const
+{
+ mi.base.bv->coordCache().insets().add(this, dim);
+}
+
+
+
/////////////////////////////////////////
bool isEditableInset(Inset const * inset)