#include "debug.h"
#include "lyxrc.h"
#include "support/lstrings.h"
+#include "BufferView.h"
#include "Painter.h"
#include "font.h"
/* 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();
}
// 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;
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;
}
-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
}
-int InsetLatexAccent::descent(Painter &, LyXFont const & font) const
+int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const
{
int max;
if (candisp) {
}
-int InsetLatexAccent::width(Painter &, LyXFont const & font) const
+int InsetLatexAccent::width(BufferView *, LyXFont const & font) const
{
if (candisp)
return lyxfont::width(ic, font);
}
-bool InsetLatexAccent::DisplayISO8859_9(Painter & pain, LyXFont const & font,
+bool InsetLatexAccent::DisplayISO8859_9(BufferView * bv, LyXFont const & font,
int baseline,
float & x) const
{
}
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
}
-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;
// 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.
}
}
} 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);
}
}
-int InsetLatexAccent::Ascii(Buffer const *, ostream & os) const
+int InsetLatexAccent::Ascii(Buffer const *, ostream & os, int) const
{
os << contents;
return 0;
}
-Inset * InsetLatexAccent::Clone() const
+Inset * InsetLatexAccent::Clone(Buffer const &) const
{
return new InsetLatexAccent(contents);
}