]> git.lyx.org Git - lyx.git/blobdiff - src/insets/insetlatexaccent.C
reformatting and remove using delc
[lyx.git] / src / insets / insetlatexaccent.C
index 62141dbfb73d10f7786c1a38b2ef1c00855e909a..2fc222f235685a339ffa1e08139c9c0f950acb73 100644 (file)
@@ -18,6 +18,7 @@
 #include "debug.h"
 #include "lyxrc.h"
 #include "support/lstrings.h"
+#include "BufferView.h"
 #include "Painter.h"
 #include "font.h"
 
@@ -29,13 +30,12 @@ using std::endl;
 /* Later modified by Lars G. Bjønnes, larsbj@lyx.org */
 
 InsetLatexAccent::InsetLatexAccent()
-{
-       candisp = false;
-}
+       : candisp(false)
+{}
 
 
-InsetLatexAccent::InsetLatexAccent(string const & string)
-       : contents(string)
+InsetLatexAccent::InsetLatexAccent(string const & str)
+       : contents(str)
 {
        checkContents();
 }
@@ -191,7 +191,7 @@ void InsetLatexAccent::checkContents()
        // special clause for \i{}, \j{} \l{} and \L{}
        if ((modtype == DOT_LESS_I || modtype == DOT_LESS_J
             || modtype == lSLASH || modtype == LSLASH)
-           && contents[3] == '}' ) {
+           && contents[3] == '}') {
                switch (modtype) {
                case DOT_LESS_I: ic = 'i'; break;
                case DOT_LESS_J: ic = 'j'; break;
@@ -225,13 +225,13 @@ void InsetLatexAccent::checkContents()
                                remdot = true;
                        else
                                return;
-               } else if ( (ic == 'i'|| ic == 'j') && contents[4] == '}') {
+               } else if ((ic == 'i'|| ic == 'j') && contents[4] == '}') {
                        // Do a rewrite: \<foo>{i} --> \<foo>{\i}
                        string temp = contents;
                        temp.erase(3, string::npos);
                        temp += '\\';
                        temp += char(ic);
-                       for(string::size_type j = 4;
+                       for (string::size_type j = 4;
                            j < contents.length(); ++j)
                                temp+= contents[j];
                        contents= temp;
@@ -254,7 +254,7 @@ void InsetLatexAccent::checkContents()
 }
 
 
-int InsetLatexAccent::ascent(Painter &, LyXFont const & font) const
+int InsetLatexAccent::ascent(BufferView *, LyXFont const & font) const
 {
        // This function is a bit too simplistix and is just a
        // "try to make a fit for all accents" approach, to
@@ -274,7 +274,7 @@ int InsetLatexAccent::ascent(Painter &, LyXFont const & font) const
 }
 
 
-int InsetLatexAccent::descent(Painter &, LyXFont const & font) const
+int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const
 {
        int max;
        if (candisp) {
@@ -290,7 +290,7 @@ int InsetLatexAccent::descent(Painter &, LyXFont const & font) const
 }
 
 
-int InsetLatexAccent::width(Painter &, LyXFont const & font) const
+int InsetLatexAccent::width(BufferView *, LyXFont const & font) const
 {
        if (candisp)
                return lyxfont::width(ic, font);
@@ -311,7 +311,7 @@ int InsetLatexAccent::Rbearing(LyXFont const & font) const
 }
 
 
-bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
+bool InsetLatexAccent::DisplayISO8859_9(BufferView * bv, LyXFont const & font,
                                        int baseline, 
                                        float & x) const
 {
@@ -345,8 +345,8 @@ bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
        }
        if (tmpic != ic) {
                char ch = char(tmpic);
-               pain.text(int(x), baseline, ch, font);
-               x += width(pain, font);
+               bv->painter().text(int(x), baseline, ch, font);
+               x += width(bv, font);
                return true;
        }
        else
@@ -354,22 +354,28 @@ bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
 }
 
 
-void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
-                           int baseline, float & x) const
+void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0,
+                           int baseline, float & x, bool) const
 {
-       if (lyxrc.font_norm == "iso8859-9")
-               if (DisplayISO8859_9(pain, font, baseline, x))  
+       Painter & pain = bv->painter();
+
+       if (lyxrc.font_norm_type == LyXRC::ISO_8859_9)
+               if (DisplayISO8859_9(bv, font0, baseline, x))   
                        return;
        
        /* draw it! */ 
        // All the manually drawn accents in this function could use an
        // overhaul. Different ways of drawing (what metrics to use)
        // should also be considered.
+
+       LyXFont font(font0);
+       if (lyxrc.font_norm_type == LyXRC::ISO_10646_1)
+               font.setLanguage(english_language);
        
        if (candisp) {
-               int asc = ascent(pain, font);
-               int desc = descent(pain, font);
-               int wid = width(pain, font);
+               int asc = ascent(bv, font);
+               int desc = descent(bv, font);
+               int wid = width(bv, font);
                float x2 = x + (Rbearing(font) - Lbearing(font)) / 2.0;
                float hg;
                int y;
@@ -409,7 +415,7 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
                        // closer to the top of the dot-less 'i' or 'j'.
                        char tmpic = ic; // store the ic when we
                        ic = 'x';        // calculates the ascent of
-                       asc = ascent(pain, font); // the dot-less version (here: 'x')
+                       asc = ascent(bv, font); // the dot-less version (here: 'x')
                        ic = tmpic;      // set the orig ic back
                        y = baseline - asc; // update to new y coord.
                }
@@ -592,26 +598,26 @@ void InsetLatexAccent::draw(Painter & pain, LyXFont const & font,
                }
        } else {
                pain.fillRectangle(int(x + 1),
-                                  baseline - ascent(pain, font) + 1,
-                                  width(pain, font) - 2,
-                                  ascent(pain, font)
-                                  + descent(pain, font) - 2);
-               pain.rectangle(int(x + 1), baseline - ascent(pain, font) + 1,
-                              width(pain, font) - 2,
-                              ascent(pain, font) + descent(pain, font) - 2);
+                                  baseline - ascent(bv, font) + 1,
+                                  width(bv, font) - 2,
+                                  ascent(bv, font)
+                                  + descent(bv, font) - 2);
+               pain.rectangle(int(x + 1), baseline - ascent(bv, font) + 1,
+                              width(bv, font) - 2,
+                              ascent(bv, font) + descent(bv, font) - 2);
                pain.text(int(x + 2), baseline, contents, font);
        }
-       x +=  width(pain, font);
+       x +=  width(bv, font);
 }
 
 
-void InsetLatexAccent::Write(ostream & os) const
+void InsetLatexAccent::Write(Buffer const *, ostream & os) const
 {
        os << "\\i " << contents << "\n";
 }
 
 
-void InsetLatexAccent::Read(LyXLex & lex)
+void InsetLatexAccent::Read(Buffer const *, LyXLex & lex)
 {
        lex.EatLine();
        contents = lex.GetString();
@@ -619,7 +625,7 @@ void InsetLatexAccent::Read(LyXLex & lex)
 }
 
 
-int InsetLatexAccent::Latex(ostream & os,
+int InsetLatexAccent::Latex(Buffer const *, ostream & os,
                            bool /*fragile*/, bool/*fs*/) const
 {
        os << contents;
@@ -627,21 +633,21 @@ int InsetLatexAccent::Latex(ostream & os,
 }
 
 
-int InsetLatexAccent::Ascii(ostream & os) const
+int InsetLatexAccent::Ascii(Buffer const *, ostream & os, int) const
 {
        os << contents;
        return 0;
 }
 
 
-int InsetLatexAccent::Linuxdoc(ostream & os) const
+int InsetLatexAccent::Linuxdoc(Buffer const *, ostream & os) const
 {
        os << contents;
        return 0;
 }
 
 
-int InsetLatexAccent::DocBook(ostream & os) const
+int InsetLatexAccent::DocBook(Buffer const *, ostream & os) const
 {
        os << contents;
        return 0;
@@ -660,7 +666,7 @@ bool InsetLatexAccent::DirectWrite() const
 }
 
 
-Inset * InsetLatexAccent::Clone() const
+Inset * InsetLatexAccent::Clone(Buffer const &) const
 {
        return new InsetLatexAccent(contents);
 }