]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetspecialchar.C
Enable convertDefault.sh to run even if its executable bit is not set.
[lyx.git] / src / insets / insetspecialchar.C
index b43100020ff99a182c97cf98bab897ac1d614633..018ac6763e3de80193be15bd41a227769b13759b 100644 (file)
@@ -7,7 +7,7 @@
  * \author Jean-Marc Lasgouttes
  * \author Lars Gullik Bjønnes
  *
- * 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;
 
 
 InsetSpecialChar::InsetSpecialChar(Kind k)
@@ -38,11 +40,11 @@ InsetSpecialChar::Kind InsetSpecialChar::kind() const
 }
 
 
-void InsetSpecialChar::dimension(BufferView *, LyXFont const & font,
-       Dimension & dim) const
+void InsetSpecialChar::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);
 
        string s;
        switch (kind_) {
@@ -52,62 +54,56 @@ void InsetSpecialChar::dimension(BufferView *, LyXFont const & font,
                case MENU_SEPARATOR:      s = " x ";   break;
                case HYPHENATION:      s = "-";   break;
        }
-       dim.w = font_metrics::width(s, font);
-       if (kind_ == HYPHENATION && dim.w > 5)
-               dim.w -= 2; // to make it look shorter
+       dim.wid = font_metrics::width(s, font);
+       if (kind_ == HYPHENATION && dim.wid > 5)
+               dim.wid -= 2; // to make it look shorter
+       dim_ = dim;
 }
 
 
-void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
-                           int baseline, float & x) const
+void InsetSpecialChar::draw(PainterInfo & pi, int x, int y) const
 {
-       Painter & pain = bv->painter();
-       LyXFont font(f);
+       LyXFont font = pi.base.font;
 
        switch (kind_) {
        case HYPHENATION:
        {
                font.setColor(LColor::special);
-               pain.text(int(x), baseline, '-', font);
-               x += width(bv, font);
+               pi.pain.text(x, y, '-', font);
                break;
        }
        case LIGATURE_BREAK:
        {
                font.setColor(LColor::special);
-               pain.text(int(x), baseline, '|', font);
-               x += width(bv, font);
+               pi.pain.text(x, y, '|', font);
                break;
        }
        case END_OF_SENTENCE:
        {
                font.setColor(LColor::special);
-               pain.text(int(x), baseline, '.', font);
-               x += width(bv, font);
+               pi.pain.text(x, y, '.', font);
                break;
        }
        case LDOTS:
        {
                font.setColor(LColor::special);
-               pain.text(int(x), baseline, ". . .", font);
-               x += width(bv, font);
+               pi.pain.text(x, y, ". . .", font);
                break;
        }
        case MENU_SEPARATOR:
        {
                // A triangle the width and height of an 'x'
                int w = font_metrics::width('x', font);
-               int ox = font_metrics::width(' ', font) + int(x);
+               int ox = font_metrics::width(' ', font) + x;
                int h = font_metrics::ascent('x', font);
                int xp[4], yp[4];
 
-               xp[0] = ox;     yp[0] = baseline;
-               xp[1] = ox;     yp[1] = baseline - h;
-               xp[2] = ox + w; yp[2] = baseline - h/2;
-               xp[3] = ox;     yp[3] = baseline;
+               xp[0] = ox;     yp[0] = y;
+               xp[1] = ox;     yp[1] = y - h;
+               xp[2] = ox + w; yp[2] = y - h/2;
+               xp[3] = ox;     yp[3] = y;
 
-               pain.lines(xp, yp, 4, LColor::special);
-               x += width(bv, font);
+               pi.pain.lines(xp, yp, 4, LColor::special);
                break;
        }
        }
@@ -115,7 +111,7 @@ void InsetSpecialChar::draw(BufferView * bv, LyXFont const & f,
 
 
 // In lyxf3 this will be just LaTeX
-void InsetSpecialChar::write(Buffer const *, ostream & os) const
+void InsetSpecialChar::write(Buffer const &, ostream & os) const
 {
        string command;
        switch (kind_) {
@@ -140,7 +136,7 @@ void InsetSpecialChar::write(Buffer const *, ostream & os) const
 
 
 // This function will not be necessary when lyx3
-void InsetSpecialChar::read(Buffer const *, LyXLex & lex)
+void InsetSpecialChar::read(Buffer const &, LyXLex & lex)
 {
        lex.nextToken();
        string const command = lex.getString();
@@ -160,7 +156,7 @@ void InsetSpecialChar::read(Buffer const *, LyXLex & lex)
 }
 
 
-int InsetSpecialChar::latex(Buffer const *, ostream & os,
+int InsetSpecialChar::latex(Buffer const &, ostream & os,
                            LatexRunParams const &) const
 {
        switch (kind_) {
@@ -184,7 +180,7 @@ int InsetSpecialChar::latex(Buffer const *, ostream & os,
 }
 
 
-int InsetSpecialChar::ascii(Buffer const *, ostream & os, int) const
+int InsetSpecialChar::ascii(Buffer const &, ostream & os, int) const
 {
        switch (kind_) {
        case HYPHENATION:
@@ -204,7 +200,7 @@ int InsetSpecialChar::ascii(Buffer const *, ostream & os, int) const
 }
 
 
-int InsetSpecialChar::linuxdoc(Buffer const *, ostream & os) const
+int InsetSpecialChar::linuxdoc(Buffer const &, ostream & os) const
 {
        switch (kind_) {
        case HYPHENATION:
@@ -224,7 +220,7 @@ int InsetSpecialChar::linuxdoc(Buffer const *, ostream & os) const
 }
 
 
-int InsetSpecialChar::docbook(Buffer const *, ostream & os, bool) const
+int InsetSpecialChar::docbook(Buffer const &, ostream & os, bool) const
 {
        switch (kind_) {
        case HYPHENATION:
@@ -244,18 +240,12 @@ int InsetSpecialChar::docbook(Buffer const *, ostream & os, bool) const
 }
 
 
-Inset * InsetSpecialChar::clone(Buffer const &) const
+auto_ptr<InsetBase> InsetSpecialChar::clone() const
 {
-       return new InsetSpecialChar(kind_);
+       return auto_ptr<InsetBase>(new InsetSpecialChar(kind_));
 }
 
 
-// Inset * InsetSpecialChar::clone(Buffer const &, bool) const
-// {
-//     return new InsetSpecialChar(kind_);
-// }
-
-
 void InsetSpecialChar::validate(LaTeXFeatures & features) const
 {
        if (kind_ == MENU_SEPARATOR) {