]> git.lyx.org Git - lyx.git/blobdiff - src/insets/InsetHFill.cpp
Embedding: display a pin at the top left corner of embedded figures
[lyx.git] / src / insets / InsetHFill.cpp
index 2c071f659fd2de70ade8e3183f408a65815d5620..76af40d23f839be8b0dcc6e3162db23d927afde1 100644 (file)
 #include <config.h>
 
 #include "InsetHFill.h"
-#include "gettext.h"
 
-#include "support/std_ostream.h"
+#include "MetricsInfo.h"
 
+#include "frontends/Painter.h"
 
-namespace lyx {
+#include "support/gettext.h"
+
+#include <ostream>
+
+using namespace std;
 
-using std::ostream;
+namespace lyx {
 
 
 InsetHFill::InsetHFill()
-       : InsetCommand(InsetCommandParams("hfill"), std::string())
+       : InsetCommand(InsetCommandParams(HFILL_CODE), string())
 {}
 
 
-std::auto_ptr<Inset> InsetHFill::doClone() const
+CommandInfo const * InsetHFill::findInfo(string const & /* cmdName */)
+{
+       static const char * const paramnames[] = {""};
+       static const CommandInfo info = {0, paramnames, 0};
+       return &info;
+}
+
+
+Inset * InsetHFill::clone() const
+{
+       return new InsetHFill;
+}
+
+
+void InsetHFill::metrics(MetricsInfo &, Dimension & dim) const
 {
-       return std::auto_ptr<Inset>(new InsetHFill);
+       // The metrics for this inset are calculated externally in
+       // \c TextMetrics::computeRowMetrics. Those are dummy value:
+       dim = Dimension(10, 10, 10);
 }
 
 
-bool InsetHFill::metrics(MetricsInfo &, Dimension & dim) const
+void InsetHFill::draw(PainterInfo & pi, int x, int y) const
 {
-       dim.wid = 3;
-       dim.asc = 3;
-       dim.des = 3;
-       bool const changed = dim_ != dim;
-       dim_ = dim;
-       return changed;
+       Dimension const dim = Inset::dimension(*pi.base.bv);
+       int const x0 = x + 1;
+       int const x1 = x + dim.wid - 2;
+       int const y0 = y + dim.des - 1;
+       int const y1 = y - dim.asc + 1;
+
+       pi.pain.line(x0, y1, x0, y0, Color_added_space);
+       pi.pain.line(x0, y, x1, y, Color_added_space,
+               frontend::Painter::line_onoffdash);
+       pi.pain.line(x1, y1, x1, y0, Color_added_space);
 }