#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();
}
plusasc = true; // at the top (not really needed)
break;
default:
- printf ("Default\n");
+ lyxerr[Debug::KEY] << "Default" << endl;
// unknow accent (or something else)
return;
}
// 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(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.
}
switch (modtype) {
case ACUTE: // acute 0xB4
{
-#if 0
- pain.line(int(x2), int(y + hg),
- int(x2 + hg35), y + hg35);
-#else
- pain.text(x2 - (lyxfont::rbearing(0xB4, font) - lyxfont::lbearing(0xB4, font)) / 2,
+ pain.text(int(x2 - (lyxfont::rbearing(0xB4, font) - lyxfont::lbearing(0xB4, font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB4, font) - (lyxfont::ascent(0xB4, font) + lyxfont::descent(0xB4, font)) / 2,
char(0xB4), font);
-#endif
break;
}
case GRAVE: // grave 0x60
{
-#if 0
- pain.line(int(x2), int(y + hg),
- int(x2 - hg35), y + hg35);
-#else
- pain.text(x2 - (lyxfont::rbearing(0x60, font) - lyxfont::lbearing(0x60, font)) / 2,
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x60, font) - (lyxfont::ascent(0x60, font) + lyxfont::descent(0x60, font)) / 2.0,
+ pain.text(int(x2 - (lyxfont::rbearing(0x60, font) - lyxfont::lbearing(0x60, font)) / 2),
+ int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x60, font) - (lyxfont::ascent(0x60, font) + lyxfont::descent(0x60, font)) / 2.0),
char(0x60), font);
-#endif
break;
}
case MACRON: // macron
{
-#if 0
- pain.line(int(x2 - wid * 0.4),
- int(y + hg),
- int(x2 + wid * 0.4),
- int(y + hg));
-#else
- pain.text(x2 - (lyxfont::rbearing(0xAF, font) - lyxfont::lbearing(0xAF, font)) / 2,
+ pain.text(int(x2 - (lyxfont::rbearing(0xAF, font) - lyxfont::lbearing(0xAF, font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xAF, font) - (lyxfont::ascent(0xAF, font) + lyxfont::descent(0xAF, font)),
char(0xAF), font);
-#endif
break;
}
case TILDE: // tilde
{
-#if 0
- if (hg35 > 2.0) hg35 -= 1.0;
- x2 += (hg35 / 2.0);
- int xp[4], yp[4];
-
- xp[0] = int(x2 - 2.0 * hg35);
- yp[0] = int(y + hg);
-
- xp[1] = int(x2 - hg35);
- yp[1] = int(y + hg35);
-
- xp[2] = int(x2);
- yp[2] = int(y + hg);
-
- xp[3] = int(x2 + hg35);
- yp[3] = int(y + hg35);
-
- pain.lines(xp, yp, 4);
-#else
- pain.text(x2 - (lyxfont::rbearing('~', font) - lyxfont::lbearing('~', font)) / 2,
+ pain.text(int(x2 - (lyxfont::rbearing('~', font) - lyxfont::lbearing('~', font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('~', font) - (lyxfont::ascent('~', font) + lyxfont::descent('~', font)) / 2,
'~', font);
-#endif
break;
}
case UNDERBAR: // underbar 0x5F
{
-#if 0
- pain.line(int(x2 - wid * 0.4),
- y + hg / 2.0,
- int(x2 + wid * 0.4),
- y + hg / 2.0);
-#else
- pain.text(x2 - (lyxfont::rbearing(0x5F, font) - lyxfont::lbearing(0x5F, font)) / 2, baseline,
+ pain.text(int(x2 - (lyxfont::rbearing(0x5F, font) - lyxfont::lbearing(0x5F, font)) / 2), baseline,
char(0x5F), font);
-#endif
break;
}
case CEDILLA: // cedilla
{
-#if 0
- int xp[4], yp[4];
-
- xp[0] = int(x2);
- yp[0] = y;
-
- xp[1] = int(x2);
- yp[1] = y + int(hg / 3.0);
-
- xp[2] = int(x2 + (hg / 3.0));
- yp[2] = y + int(hg / 2.0);
-
- xp[3] = int(x2 - (hg / 4.0));
- yp[3] = y + int(hg);
-
- pain.lines(xp, yp, 4);
-#else
- pain.text(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2, baseline,
+ pain.text(int(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2), baseline,
char(0xB8), font);
-#endif
break;
}
case UNDERDOT: // underdot
{
-#if 0
- pain.arc(int(x2), y + hg35,
- 3, 3, 0, 360 * 64);
-#else
- pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0,
- baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font)),
+ pain.text(int(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0),
+ int(baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font))),
'.', font);
-#endif
break;
}
case DOT: // dot
{
-#if 0
- pain.arc(int(x2), y + hg * 0.5,
- (hg + 3.0)/5.0,
- (hg + 3.0)/5.0,
- 0, 360 * 64);
-#else
- pain.text(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0,
+ pain.text(int(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('.', font) - (lyxfont::ascent('.', font) + lyxfont::descent('.', font)) / 2,
'.', font);
-#endif
break;
}
case CIRCLE: // circle
{
-#if 0
- pain.arc(int(x2 - (hg / 2.0)),
- y + (hg / 2.0), hg, hg , 0,
- 360 * 64);
-#else
LyXFont tmpf(font);
tmpf.decSize().decSize();
- pain.text(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0,
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB0, tmpf) - (lyxfont::ascent(0xB0, tmpf) + lyxfont::descent(0xB0, tmpf)) / 3.0,
+ pain.text(int(x2 - (lyxfont::rbearing(0xB0, tmpf) - lyxfont::lbearing(0xB0, tmpf)) / 2.0),
+ int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0xB0, tmpf) - (lyxfont::ascent(0xB0, tmpf) + lyxfont::descent(0xB0, tmpf)) / 3.0),
char(0xB0), tmpf);
-#endif
break;
}
case TIE: // tie
{
- pain.arc(int(x2 + hg35), y + hg / 2.0,
- 2 * hg, hg, 0, 360 * 32);
+ pain.arc(int(x2 + hg35), int(y + hg / 2.0),
+ int(2 * hg), int(hg), 0, 360 * 32);
break;
}
case BREVE: // breve
{
pain.arc(int(x2 - (hg / 2.0)), y,
- hg, hg, 0, -360*32);
+ int(hg), int(hg), 0, -360*32);
break;
}
case CARON: // caron
}
case HUNGARIAN_UMLAUT: // hung. umlaut
{
-#if 0
- int xs1[2], xs2[2], ys1[2], ys2[2];
-
- xs1[0] = int(x2 - (hg / 2.0));
- ys1[0] = int(y + hg);
-
- xs2[0] = int(x2 + hg35 - (hg / 2.0));
- ys2[0] = int(y + hg35);
-
- xs1[1] = int(x2 + (hg / 2.0));
- ys1[1] = int(y + hg);
-
- xs2[1] = int(x2 + hg35 + (hg / 2.0));
- ys2[1] = int(y + hg35);
-
- pain.segments(xs1, ys1, xs2, ys2, 2);
-#else
- pain.text(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font)),
+ pain.text(int(x2 - (lyxfont::rbearing('´', font) - lyxfont::lbearing('´', font))),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
'´', font);
- pain.text(x2,
+ pain.text(int(x2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2,
'´', font);
-#endif
break;
}
case UMLAUT: // umlaut
{
-#if 0
- float rad = hg / 2.0;
- if (rad <= 1.0) {
- pain.point(int(x2 - 4.0 * hg / 7.0),
- y + hg35);
- pain.point(int(x2 + 4.0 * hg / 7.0),
- y + hg35);
- } else {
- rad += .5; // this ensures that f.ex. 1.5 will
- // not be rounded down to .5 and then
- // converted to int = 0
- pain.arc(int(x2 - 2.0 * hg / 4.0),
- y + hg35,
- rad, rad,
- 0, 360 * 64);
- pain.arc(int(x2 + 2.0 * hg / 4.0),
- y + hg35,
- rad, rad, 0, 360*64);
- }
-#else
- pain.text(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2,
+ pain.text(int(x2 - (lyxfont::rbearing('¨', font) - lyxfont::lbearing('¨', font)) / 2),
baseline - lyxfont::ascent(ic, font) - lyxfont::descent('¨', font) - ( lyxfont::ascent('¨', font) + lyxfont::descent('¨', font)) / 2,
'¨', font);
-#endif
break;
}
case CIRCUMFLEX: // circumflex
{
-#if 0
- int xp[3], yp[3];
-
- xp[0] = int(x2 - hg35); yp[0] = y + int(hg);
- xp[1] = int(x2); yp[1] = int(y + hg35);
- xp[2] = int(x2 + hg35); yp[2] = y + int(hg);
- pain.lines(xp, yp, 3);
-#else
LyXFont tmpf(font);
tmpf.decSize().decSize().decSize();
- pain.text(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2,
- baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0,
+ pain.text(int(x2 - (lyxfont::rbearing(0x5E, tmpf) - lyxfont::lbearing(0x5E, tmpf)) / 2),
+ int(baseline - lyxfont::ascent(ic, font) - lyxfont::descent(0x5E, tmpf) - (lyxfont::ascent(0x5E, tmpf) + lyxfont::descent(0x5E, tmpf)) / 3.0),
char(0x5E), tmpf);
-#endif
break;
}
case OGONEK: // ogonek
}
} 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();
}
-int InsetLatexAccent::Latex(ostream & os,
- signed char /*fragile*/, bool/*fs*/) const
+int InsetLatexAccent::Latex(Buffer const *, ostream & os,
+ bool /*fragile*/, bool/*fs*/) const
+{
+ os << contents;
+ return 0;
+}
+
+
+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;
}
-Inset * InsetLatexAccent::Clone() const
+Inset * InsetLatexAccent::Clone(Buffer const &) const
{
return new InsetLatexAccent(contents);
}