]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetquotes.C
Enable the external inset to handle unknown templates gracefully.
[lyx.git] / src / insets / insetquotes.C
index 8d38abee11c711bbddd18ce309ccb38d8be01094..3d7d57b42c54e4c6646db4de87e1238a031f1d66 100644 (file)
@@ -23,6 +23,7 @@
 #include "lyxlex.h"
 #include "lyxrc.h"
 #include "paragraph.h"
+#include "metricsinfo.h"
 #include "frontends/font_metrics.h"
 #include "frontends/Painter.h"
 #include "support/LAssert.h"
@@ -170,21 +171,21 @@ string const InsetQuotes::dispString(Language const * loclang) const
 }
 
 
-void InsetQuotes::dimension(BufferView *, LyXFont const & font,
-       Dimension & dim) const
+void InsetQuotes::metrics(MetricsInfo & mi, Dimension & dim) const
 {
-       dim.a = font_metrics::maxAscent(font);
-       dim.d = font_metrics::maxDescent(font);
-       dim.w = 0;
+       LyXFont & font = mi.base.font;
+       dim.asc = font_metrics::maxAscent(font);
+       dim.des = font_metrics::maxDescent(font);
+       dim.wid = 0;
 
        string const text = dispString(font.language());
        for (string::size_type i = 0; i < text.length(); ++i) {
                if (text[i] == ' ')
-                       dim.w += font_metrics::width('i', font);
+                       dim.wid += font_metrics::width('i', font);
                else if (i == 0 || text[i] != text[i - 1])
-                       dim.w += font_metrics::width(text[i], font);
+                       dim.wid += font_metrics::width(text[i], font);
                else
-                       dim.w += font_metrics::width(',', font);
+                       dim.wid += font_metrics::width(',', font);
        }
 }
 
@@ -202,18 +203,17 @@ LyXFont const InsetQuotes::convertFont(LyXFont const & f) const
 #endif
 
 
-void InsetQuotes::draw(BufferView * bv, LyXFont const & font,
-                      int baseline, float & x) const
+void InsetQuotes::draw(PainterInfo & pi, int x, int y) const
 {
-       string const text = dispString(font.language());
+       string const text = dispString(pi.base.font.language());
 
        if (text.length() == 2 && text[0] == text[1]) {
-               bv->painter().text(int(x), baseline, text[0], font);
-               int x2 = int(x + font_metrics::width(',', font));
-               bv->painter().text(x2, baseline, text[0], font);
-       } else
-               bv->painter().text(int(x), baseline, text, font);
-       x += width(bv, font);
+               pi.pain.text(x, y, text[0], pi.base.font);
+               int const t = font_metrics::width(',', pi.base.font);
+               pi.pain.text(x + t, y, text[0], pi.base.font);
+       } else {
+               pi.pain.text(x, y, text, pi.base.font);
+       }
 }
 
 
@@ -239,8 +239,7 @@ void InsetQuotes::read(Buffer const *, LyXLex & lex)
 
 
 int InsetQuotes::latex(Buffer const * buf, ostream & os,
-                      LatexRunParams const & runparams,
-                      bool /* free_spc */) const
+                      LatexRunParams const & runparams) const
 {
        // How do we get the local language here??
        lyx::pos_type curr_pos = parOwner()->getPositionOfInset(this);
@@ -323,10 +322,9 @@ int InsetQuotes::docbook(Buffer const *, ostream & os, bool) const
 }
 
 
-extern bool use_babel;
-
 void InsetQuotes::validate(LaTeXFeatures & features) const
 {
+       bool const use_babel = features.useBabel();
        char type = quote_char[quote_index[side_][language_]];
 
 #ifdef DO_USE_DEFAULT_LANGUAGE
@@ -337,7 +335,7 @@ void InsetQuotes::validate(LaTeXFeatures & features) const
            && lyxrc.fontenc != "T1") {
                if (times_ == SingleQ)
                        switch (type) {
-                       case ',': features.require("quotesinglbase");  break;
+                               case ',': features.require("quotesinglbase");  break;
                        case '<': features.require("guilsinglleft");  break;
                        case '>': features.require("guilsinglright"); break;
                        default: break;
@@ -353,9 +351,9 @@ void InsetQuotes::validate(LaTeXFeatures & features) const
 }
 
 
-Inset * InsetQuotes::clone(Buffer const &, bool) const
+Inset * InsetQuotes::clone() const
 {
-  return new InsetQuotes(language_, side_, times_);
+       return new InsetQuotes(language_, side_, times_);
 }