]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetspace.C
Enable convertDefault.sh to run even if its executable bit is not set.
[lyx.git] / src / insets / insetspace.C
index d0b15c8903002795d369a60e6915f717c8a8d3cc..801bf188bd99d602ac500d167d3fa77063ba8f99 100644 (file)
@@ -8,7 +8,7 @@
  * \author Lars Gullik Bjønnes
  * \author Juergen Spitzmueller
  *
- * Full author contact details are available in file CREDITS
+ * Full author contact details are available in file CREDITS.
  */
 
 #include <config.h>
 #include "frontends/font_metrics.h"
 #include "lyxlex.h"
 #include "lyxfont.h"
+#include "metricsinfo.h"
 
 using std::ostream;
 using std::max;
+using std::auto_ptr;
+
+
+InsetSpace::InsetSpace()
+{}
 
 
 InsetSpace::InsetSpace(Kind k)
@@ -40,64 +46,62 @@ InsetSpace::Kind InsetSpace::kind() const
 }
 
 
-void InsetSpace::dimension(BufferView *, LyXFont const & font,
-                          Dimension & dim) const
+void InsetSpace::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       dim.a = font_metrics::maxAscent(font);
-       dim.d = font_metrics::maxDescent(font);
+       LyXFont & font = mi.base.font;
+       dim.asc = font_metrics::maxAscent(font);
+       dim.des = font_metrics::maxDescent(font);
 
        switch (kind_) {
                case THIN:
                case NEGTHIN:
-                       dim.w = font_metrics::width("x", font) / 3;
+                       dim.wid = font_metrics::width("x", font) / 3;
                        break;
                case PROTECTED:
                case NORMAL:
-                       dim.w = font_metrics::width("x", font);
+                       dim.wid = font_metrics::width("x", font);
                        break;
                case QUAD:
-                       dim.w = 20;
+                       dim.wid = 20;
                        break;
                case QQUAD:
-                       dim.w = 40;
+                       dim.wid = 40;
                        break;
                case ENSPACE:
                case ENSKIP:
-                       dim.w = 10;
+                       dim.wid = 10;
                        break;
        }
+       dim_ = dim;
 }
 
 
-void InsetSpace::draw(BufferView * bv, LyXFont const & f,
-                           int baseline, float & x) const
+void InsetSpace::draw(PainterInfo & pi, int x, int y) const
 {
-       Painter & pain = bv->painter();
-       LyXFont font(f);
-
-       float w = width(bv, font);
-       int h = font_metrics::ascent('x', font);
+       int const w = width();
+       int const h = font_metrics::ascent('x', pi.base.font);
        int xp[4], yp[4];
 
-       xp[0] = int(x); yp[0] = baseline - max(h / 4, 1);
+       xp[0] = x;
+       yp[0] = y - max(h / 4, 1);
        if (kind_ == NORMAL) {
-               xp[1] = int(x); yp[1] = baseline;
-               xp[2] = int(x + w); yp[2] = baseline;
+               xp[1] = x;     yp[1] = y;
+               xp[2] = x + w; yp[2] = y;
        } else {
-               xp[1] = int(x); yp[1] = baseline + max(h / 4, 1);
-               xp[2] = int(x + w); yp[2] = baseline + max(h / 4, 1);
+               xp[1] = x;     yp[1] = y + max(h / 4, 1);
+               xp[2] = x + w; yp[2] = y + max(h / 4, 1);
        }
-       xp[3] = int(x + w); yp[3] = baseline - max(h / 4, 1);
+       xp[3] = x + w;
+       yp[3] = y - max(h / 4, 1);
 
        if (kind_ == PROTECTED || kind_ == ENSPACE || kind_ == NEGTHIN)
-               pain.lines(xp, yp, 4, LColor::latex);
+               pi.pain.lines(xp, yp, 4, LColor::latex);
        else
-               pain.lines(xp, yp, 4, LColor::special);
-       x += w;
+               pi.pain.lines(xp, yp, 4, LColor::special);
 }
 
 
-void InsetSpace::write(Buffer const *, ostream & os) const
+void InsetSpace::write(Buffer const &, ostream & os) const
 {
        string command;
        switch (kind_) {
@@ -131,7 +135,7 @@ void InsetSpace::write(Buffer const *, ostream & os) const
 
 
 // This function will not be necessary when lyx3
-void InsetSpace::read(Buffer const *, LyXLex & lex)
+void InsetSpace::read(Buffer const &, LyXLex & lex)
 {
        lex.nextToken();
        string const command = lex.getString();
@@ -157,7 +161,7 @@ void InsetSpace::read(Buffer const *, LyXLex & lex)
 }
 
 
-int InsetSpace::latex(Buffer const *, ostream & os,
+int InsetSpace::latex(Buffer const &, ostream & os,
                      LatexRunParams const & runparams) const
 {
        switch (kind_) {
@@ -190,7 +194,7 @@ int InsetSpace::latex(Buffer const *, ostream & os,
 }
 
 
-int InsetSpace::ascii(Buffer const *, ostream & os, int) const
+int InsetSpace::ascii(Buffer const &, ostream & os, int) const
 {
        switch (kind_) {
        case NORMAL:
@@ -208,10 +212,9 @@ int InsetSpace::ascii(Buffer const *, ostream & os, int) const
 }
 
 
-int InsetSpace::linuxdoc(Buffer const *, ostream & os) const
+int InsetSpace::linuxdoc(Buffer const &, ostream & os) const
 {
        switch (kind_) {
-       // fixme: correct?
        case NORMAL:
        case QUAD:
        case QQUAD:
@@ -229,10 +232,9 @@ int InsetSpace::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetSpace::docbook(Buffer const *, ostream & os, bool) const
+int InsetSpace::docbook(Buffer const &, ostream & os, bool) const
 {
        switch (kind_) {
-       // fixme: correct?
        case NORMAL:
        case QUAD:
        case QQUAD:
@@ -250,18 +252,12 @@ int InsetSpace::docbook(Buffer const *, ostream & os, bool) const
 }
 
 
-Inset * InsetSpace::clone(Buffer const &) const
+auto_ptr<InsetBase>  InsetSpace::clone() const
 {
-       return new InsetSpace(kind_);
+       return auto_ptr<InsetBase>(new InsetSpace(kind_));
 }
 
 
-// Inset * InsetSpace::clone(Buffer const &, bool) const
-// {
-//     return new InsetSpace(kind_);
-// }
-
-
 bool InsetSpace::isChar() const
 {
        return true;