X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=src%2Finsets%2Finsetlatexaccent.C;h=94c1e2b19c0757d3e573aefdb98a01c2f925b77e;hb=e28331ed63062dea10d0a21b9ec12034b4b17b9a;hp=555cdd8925058174b528f8049490a79b42cb25a4;hpb=85a5ea7bfc80e179a61a99f2955455e84d3384cc;p=lyx.git diff --git a/src/insets/insetlatexaccent.C b/src/insets/insetlatexaccent.C index 555cdd8925..94c1e2b19c 100644 --- a/src/insets/insetlatexaccent.C +++ b/src/insets/insetlatexaccent.C @@ -1,30 +1,40 @@ -/* This file is part of - * ====================================================== - * - * LyX, The Document Processor - * - * Copyright 1995 Matthias Ettrich - * Copyright 1995-2001 The LyX Team. +/** + * \file insetlatexaccent.C + * This file is part of LyX, the document processor. + * Licence details can be found in the file COPYING. * - * ====================================================== */ + * \author Lars Gullik Bjønnes + * + * Full author contact details are available in file CREDITS. + */ #include -#ifdef __GNUG__ -#pragma implementation -#endif - #include "insetlatexaccent.h" + #include "debug.h" +#include "language.h" +#include "LColor.h" +#include "lyxlex.h" #include "lyxrc.h" +#include "metricsinfo.h" + +#include "frontends/FontMetrics.h" +#include "frontends/Painter.h" + #include "support/lstrings.h" -#include "BufferView.h" -#include "Painter.h" -#include "font.h" -#include "language.h" -using std::ostream; + +namespace lyx { + +using support::contains; +using support::trim; + using std::endl; +using std::string; +using std::auto_ptr; +using std::ostream; + /* LatexAccent. Proper handling of accented characters */ /* This part is done by Ivan Schreter, schreter@ccsun.tuke.sk */ @@ -42,122 +52,99 @@ InsetLatexAccent::InsetLatexAccent(string const & str) } +auto_ptr InsetLatexAccent::doClone() const +{ + return auto_ptr(new InsetLatexAccent(contents)); +} + + void InsetLatexAccent::checkContents() - // check, if we know the modifier and can display it ok on screen + // check, if we know the modifier and can display it ok on screen { - candisp = false; - - if (contents.empty() || contents.length() < 2) return; - - // REMOVE IN 0.13 - // Dirty Hack for backward compability. remove in 0.13 (Lgb) - contents = frontStrip(strip(contents)); - if (!contains(contents, "{") && !contains(contents, "}")) { - if (contents.length() == 2) { - string tmp; - tmp += contents[0]; - tmp += contents[1]; - tmp += "{}"; - contents = tmp; - } else if (contents.length() == 3) { - string tmp; - tmp += contents[0]; - tmp += contents[1]; - tmp += '{'; - tmp += contents[2]; - tmp += '}'; - contents = tmp; - } else if (contents.length() == 4 && contents[2] == ' ') { - string tmp; - tmp += contents[0]; - tmp += contents[1]; - tmp += '{'; - tmp += contents[3]; - tmp += '}'; - contents = tmp; - } else if (contents.length() == 4 && contents[2] == '\\' - && (contents[3] == 'i' || contents[3] == 'j')) { - string tmp; - tmp += contents[0]; - tmp += contents[1]; - tmp += '{'; - tmp += contents[2]; - tmp += contents[3]; - tmp += '}'; - contents = tmp; - } + candisp = false; + + if (contents.empty() || contents.length() < 2) { + lyxerr[Debug::KEY] << "Cannot decode: " << contents << endl; + return; + } + + contents = trim(contents); + if (contents[0] != '\\') { // demand that first char is a '\\' + lyxerr[Debug::KEY] << "Cannot decode: " << contents << endl; + return; } - if (contents[0] != '\\') return; // demand that first char is a '\\' lyxerr[Debug::KEY] << "Decode: " << contents << endl; - remdot = false; plusasc = false; plusdesc = false; + remdot = false; + plusasc = false; + plusdesc = false; - switch (contents[1]) { // second char should be one of these + switch (contents[1]) { // second char should be one of these case '\'': // acute - modtype = ACUTE; // acute - plusasc = true; // at the top of character - break; + modtype = ACUTE; // acute + plusasc = true; // at the top of character + break; case '`': // grave - modtype = GRAVE; // grave - plusasc = true; // at the top - break; + modtype = GRAVE; // grave + plusasc = true; // at the top + break; case '=': // macron - modtype = MACRON; // macron - plusasc = true; // at the top - break; + modtype = MACRON; // macron + plusasc = true; // at the top + break; case '~': // tilde - modtype = TILDE; // tilde - plusasc = true; // at the top - break; + modtype = TILDE; // tilde + plusasc = true; // at the top + break; case 'b': // underbar - modtype = UNDERBAR; // underbar - plusdesc = true; // at the bottom - break; + modtype = UNDERBAR; // underbar + plusdesc = true; // at the bottom + break; case 'c': // cedilla - modtype = CEDILLA; // cedilla - plusdesc = true; // at the bottom - break; + modtype = CEDILLA; // cedilla + plusdesc = true; // at the bottom + break; case 'd': // underdot - modtype = UNDERDOT; // underdot - plusdesc = true; // at the bottom - break; + modtype = UNDERDOT; // underdot + plusdesc = true; // at the bottom + break; case 'r': // circle - modtype = CIRCLE; // circle - plusasc = true; // at the top - break; + modtype = CIRCLE; // circle + plusasc = true; // at the top + break; case 't': // tie - modtype = TIE; // tie - plusasc = true; // at the top - break; + modtype = TIE; // tie + plusasc = true; // at the top + break; case 'u': // breve - modtype = BREVE; // breve - plusasc = true; // at the top - break; + modtype = BREVE; // breve + plusasc = true; // at the top + break; case 'v': // caron - modtype = CARON; // caron - plusasc = true; // at the top - break; + modtype = CARON; // caron + plusasc = true; // at the top + break; case 'q': // special caron - modtype = SPECIAL_CARON; // special caron - plusasc = true; // at the top - break; + modtype = SPECIAL_CARON; // special caron + plusasc = true; // at the top + break; case 'H': // hungarian umlaut - modtype = HUNGARIAN_UMLAUT; // hungarian umlaut - plusasc = true; // at the top - break; + modtype = HUNGARIAN_UMLAUT; // hungarian umlaut + plusasc = true; // at the top + break; case '"': // umlaut - modtype = UMLAUT; // umlaut - plusasc = true; // at the top - break; + modtype = UMLAUT; // umlaut + plusasc = true; // at the top + break; case '.': // dot - modtype = DOT; // dot - plusasc = true; // at the top - break; + modtype = DOT; // dot + plusasc = true; // at the top + break; case '^': // circumflex - modtype = CIRCUMFLEX; // circumflex - plusasc = true; // at the top - break; + modtype = CIRCUMFLEX; // circumflex + plusasc = true; // at the top + break; case 'k': // ogonek modtype = OGONEK; // ogonek plusdesc = true; @@ -172,19 +159,19 @@ void InsetLatexAccent::checkContents() plusasc = true; // at the top (not really needed) remdot = true; break; - case 'l': // lslash - modtype = lSLASH; - plusasc = true; // at the top (not really needed) - break; - case 'L': // lslash - modtype = LSLASH; - plusasc = true; // at the top (not really needed) - break; + case 'l': // lslash + modtype = lSLASH; + plusasc = true; // at the top (not really needed) + break; + case 'L': // lslash + modtype = LSLASH; + plusasc = true; // at the top (not really needed) + break; default: lyxerr[Debug::KEY] << "Default" << endl; - // unknow accent (or something else) - return; - } + // unknown accent (or something else) + return; + } // we demand that third char is a '{' (Lgb) if (contents[2] != '{') return; @@ -204,18 +191,18 @@ void InsetLatexAccent::checkContents() break; } //ic = (modtype == DOT_LESS_J ? 'j' : 'i'); - lyxerr[Debug::KEY] << "Contents: [" << contents << "]" - << ", ic: " << ic - << ", top: " << plusasc - << ", bot: " << plusdesc - << ", dot: " << remdot + lyxerr[Debug::KEY] << "Contents: [" << contents << ']' + << ", ic: " << ic + << ", top: " << plusasc + << ", bot: " << plusdesc + << ", dot: " << remdot << ", mod: " << modtype << endl; // Special case for space } else if (contents[3] == '}') { ic = ' '; } else { int i = 3; - + // now get the char ic = contents[3]; // i will always be 3 here @@ -238,426 +225,383 @@ void InsetLatexAccent::checkContents() contents= temp; ++i; remdot = true; - } + } // demand a '}' at the end if (contents[++i] != '}' && contents[++i]) return; - + // fine, the char is properly decoded now (hopefully) - lyxerr[Debug::KEY] << "Contents: [" << contents << "]" + lyxerr[Debug::KEY] << "Contents: [" << contents << ']' << ", ic: " << ic - << ", top: " << plusasc - << ", bot: " << plusdesc + << ", top: " << plusasc + << ", bot: " << plusdesc << ", dot: " << remdot << ", mod: " << modtype << endl; } - candisp = true; + candisp = true; } -int InsetLatexAccent::ascent(BufferView *, LyXFont const & font) const +bool InsetLatexAccent::metrics(MetricsInfo & mi, Dimension & dim) const { - // This function is a bit too simplistix and is just a + LyXFont & font = mi.base.font; + frontend::FontMetrics const & fm = theFontMetrics(font); + + // This function is a bit too simplistic and is just a // "try to make a fit for all accents" approach, to // make it better we need to know what kind of accent is // used and add to max based on that. - int max; if (candisp) { if (ic == ' ') - max = lyxfont::ascent('a', font); + dim.asc = fm.ascent('a'); else - max = lyxfont::ascent(ic, font); - if (plusasc) - max += (lyxfont::maxAscent(font) + 3) / 3; - } else - max = lyxfont::maxAscent(font) + 4; - return max; -} - - -int InsetLatexAccent::descent(BufferView *, LyXFont const & font) const -{ - int max; - if (candisp) { - if (ic == ' ') - max = lyxfont::descent('a', font); - else - max = lyxfont::descent(ic, font); - if (plusdesc) - max += 3; - } else - max = lyxfont::maxDescent(font) + 4; - return max; -} - - -int InsetLatexAccent::width(BufferView *, LyXFont const & font) const -{ - if (candisp) - return lyxfont::width(ic, font); - else - return lyxfont::width(contents, font) + 4; -} - - -int InsetLatexAccent::lbearing(LyXFont const & font) const -{ - return lyxfont::lbearing(ic, font); -} + dim.asc = fm.ascent(ic); + if (plusasc) + dim.asc += (fm.maxAscent() + 3) / 3; + if (ic == ' ') + dim.des = fm.descent('a'); + else + dim.des = fm.descent(ic); + if (plusdesc) + dim.des += 3; -int InsetLatexAccent::rbearing(LyXFont const & font) const -{ - return lyxfont::rbearing(ic, font); + dim.wid = fm.width(ic); + } else { + dim.asc = fm.maxAscent() + 4; + dim.des = fm.maxDescent() + 4; + docstring dcon(contents.begin(), contents.end()); + dim.wid = fm.width(dcon) + 4; + } + bool const changed = dim_ != dim; + dim_ = dim; + return changed; } -bool InsetLatexAccent::displayISO8859_9(BufferView * bv, LyXFont const & font, - int baseline, - float & x) const +bool InsetLatexAccent::displayISO8859_9(PainterInfo & pi, int x, int y) const { unsigned char tmpic = ic; - + switch (modtype) { - case CEDILLA: - { - if (ic == 'c') tmpic = 0xe7; - if (ic == 'C') tmpic = 0xc7; - if (ic == 's') tmpic = 0xfe; - if (ic == 'S') tmpic = 0xde; + + case CEDILLA: { + if (ic == 'c') tmpic = '\xe7'; + if (ic == 'C') tmpic = '\xc7'; + if (ic == 's') tmpic = '\xfe'; + if (ic == 'S') tmpic = '\xde'; break; } - case BREVE: - { if (ic == 'g') tmpic = 0xf0; - if (ic == 'G') tmpic = 0xd0; - break; - } - case UMLAUT: - { - if (ic == 'o') tmpic = 0xf6; - if (ic == 'O') tmpic = 0xd6; - if (ic == 'u') tmpic = 0xfc; - if (ic == 'U') tmpic = 0xdc; + + case BREVE: { + if (ic == 'g') tmpic = '\xf0'; + if (ic == 'G') tmpic = '\xd0'; break; } - case DOT: if (ic == 'I') tmpic = 0xdd; break; - case DOT_LESS_I: tmpic = 0xfd; break; - default: return false; + + case UMLAUT: { + if (ic == 'o') tmpic = '\xf6'; + if (ic == 'O') tmpic = '\xd6'; + if (ic == 'u') tmpic = '\xfc'; + if (ic == 'U') tmpic = '\xdc'; + break; } - if (tmpic != ic) { - char ch = char(tmpic); - bv->painter().text(int(x), baseline, ch, font); - x += width(bv, font); - return true; + + case DOT: + if (ic == 'I') tmpic = '\xdd'; + break; + + case DOT_LESS_I: + tmpic = '\xfd'; + break; + + default: + return false; } - else + + if (tmpic == ic) return false; + + pi.pain.text(x, y, char(tmpic), pi.base.font); + return true; } -void InsetLatexAccent::draw(BufferView * bv, LyXFont const & font0, - int baseline, float & x, bool) const +void InsetLatexAccent::drawAccent(PainterInfo const & pi, int x, int y, + char_type accent) const { - Painter & pain = bv->painter(); + LyXFont const & font = pi.base.font; + frontend::FontMetrics const & fm = theFontMetrics(font); + + x -= fm.center(accent); + y -= fm.ascent(ic); + y -= fm.descent(accent); + y -= fm.height(accent) / 2; + pi.pain.text(x, y, accent, font); +} + +void InsetLatexAccent::draw(PainterInfo & pi, int x, int baseline) const +{ if (lyxrc.font_norm_type == LyXRC::ISO_8859_9) - if (displayISO8859_9(bv, font0, baseline, x)) + if (displayISO8859_9(pi, x, baseline)) 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); + LyXFont font = pi.base.font; if (lyxrc.font_norm_type == LyXRC::ISO_10646_1) font.setLanguage(english_language); - + + frontend::FontMetrics const & fm = theFontMetrics(font); + if (candisp) { - 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 x2 = int(x + (fm.rbearing(ic) - fm.lbearing(ic)) / 2); + int hg; int y; if (plusasc) { // mark at the top - hg = lyxfont::maxDescent(font); - y = baseline - asc; - + hg = fm.maxDescent(); + y = baseline - dim_.asc; if (font.shape() == LyXFont::ITALIC_SHAPE) - x2 += (4.0 * hg) / 5.0; // italic + x2 += int(0.8 * hg); // italic } else { // at the bottom - hg = desc; + hg = dim_.des; y = baseline; } - float hg35 = float(hg * 3.0) / 5.0; + double hg35 = hg * 0.6; // display with proper accent mark // first the letter - pain.text(int(x), baseline, ic, font); + pi.pain.text(x, baseline, ic, font); if (remdot) { - int tmpvar = baseline - lyxfont::ascent('i', font); - float tmpx = 0; + int tmpvar = baseline - fm.ascent('i'); + int tmpx = 0; if (font.shape() == LyXFont::ITALIC_SHAPE) - tmpx += (8.0 * hg) / 10.0; // italic + tmpx += int(0.8 * hg); // italic lyxerr[Debug::KEY] << "Removing dot." << endl; // remove the dot first - pain.fillRectangle(int(x + tmpx), tmpvar, wid, - lyxfont::ascent('i', font) - - lyxfont::ascent('x', font) - 1, - LColor::background); + pi.pain.fillRectangle(x + tmpx, tmpvar, dim_.wid, + fm.ascent('i') - + fm.ascent('x') - 1, + backgroundColor()); // the five lines below is a simple hack to // make the display of accent 'i' and 'j' // better. It makes the accent be written // 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(bv, font); // the dot-less version (here: 'x') +#ifdef WITH_WARNINGS +#warning metrics? +#endif + int asc = ascent(); // the dot-less version (here: 'x') ic = tmpic; // set the orig ic back y = baseline - asc; // update to new y coord. } - // now the rest - draw within (x, y, x+wid, y+hg) + + // now the rest - draw within (x, y, x + wid, y + hg) switch (modtype) { - case ACUTE: // acute 0xB4 - { - 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); + case ACUTE: + //drawAccent(pi, x2, baseline, '\xB4'); + drawAccent(pi, x2, baseline, 0xB4); break; - } - case GRAVE: // grave 0x60 - { - 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); + + case GRAVE: + //drawAccent(pi, x2, baseline, '\x60'); + drawAccent(pi, x2, baseline, 0x60); break; - } - case MACRON: // macron - { - 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); + + case MACRON: + //drawAccent(pi, x2, baseline, '\xAF'); + drawAccent(pi, x2, baseline, 0xAF); break; - } - case TILDE: // tilde - { - 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); + + case TILDE: + drawAccent(pi, x2, baseline, '~'); break; - } - case UNDERBAR: // underbar 0x5F - { - pain.text(int(x2 - (lyxfont::rbearing(0x5F, font) - lyxfont::lbearing(0x5F, font)) / 2), baseline, - char(0x5F), font); + + case UNDERBAR: { + char_type const underbar = 0x5F; //('\x5F'); + pi.pain.text(x2 - fm.center(underbar), + baseline, underbar, font); break; } - case CEDILLA: // cedilla - { - pain.text(int(x2 - (lyxfont::rbearing(0xB8, font) - lyxfont::lbearing(0xB8, font)) / 2), baseline, - char(0xB8), font); - + + case CEDILLA: { + char_type const cedilla = 0xB8; //('\xB8'); + pi.pain.text(x2 - fm.center(cedilla), + baseline, cedilla, font); break; } - case UNDERDOT: // underdot - { - pain.text(int(x2 - (lyxfont::rbearing('.', font) - lyxfont::lbearing('.', font)) / 2.0), - int(baseline + 3.0 / 2.0 * (lyxfont::ascent('.', font) + lyxfont::descent('.', font))), + + case UNDERDOT: + pi.pain.text(x2 - fm.center('.'), + int(baseline + 1.5 * fm.height('.')), '.', font); break; - } - case DOT: // dot - { - 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); + case DOT: + drawAccent(pi, x2, baseline, '.'); break; - } - case CIRCLE: // circle - { - LyXFont tmpf(font); - tmpf.decSize().decSize(); - 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); + case CIRCLE: + //drawAccent(pi, x2, baseline, '\xB0'); + drawAccent(pi, x2, baseline, 0xB0); break; - } - case TIE: // tie - { - pain.arc(int(x2 + hg35), int(y + hg / 2.0), - int(2 * hg), int(hg), 0, 360 * 32); + + case TIE: + pi.pain.arc(int(x2 + hg35), y + hg / 2, 2 * hg, hg, 0, 360 * 32, + LColor::foreground); break; - } - case BREVE: // breve - { - pain.arc(int(x2 - (hg / 2.0)), y, - int(hg), int(hg), 0, -360*32); + + case BREVE: + pi.pain.arc(int(x2 - hg / 2), y, hg, hg, 0, -360*32, + LColor::foreground); break; - } - case CARON: // caron - { + + case CARON: { int xp[3], yp[3]; - - xp[0] = int(x2 - hg35); yp[0] = int(y + hg35); - xp[1] = int(x2); yp[1] = int(y + hg); - xp[2] = int(x2 + hg35); yp[2] = int(y + hg35); - pain.lines(xp, yp, 3); + xp[0] = int(x2 - hg35); yp[0] = int(y + hg35); + xp[1] = int(x2); yp[1] = int(y + hg); + xp[2] = int(x2 + hg35); yp[2] = int(y + hg35); + pi.pain.lines(xp, yp, 3, LColor::foreground); break; } - case SPECIAL_CARON: // special caron - { + + case SPECIAL_CARON: { switch (ic) { - case 'L': wid = int(4.0 * wid / 5.0); break; - case 't': y -= int(hg35 / 2.0); break; + case 'L': dim_.wid = int(4.0 * dim_.wid / 5.0); break; + case 't': y -= int(hg35 / 2.0); break; } int xp[3], yp[3]; - xp[0] = int(x + wid); + xp[0] = int(x + dim_.wid); yp[0] = int(y + hg35 + hg); - - xp[1] = int(x + wid + (hg35 / 2.0)); + + xp[1] = int(x + dim_.wid + (hg35 / 2.0)); yp[1] = int(y + hg + (hg35 / 2.0)); - - xp[2] = int(x + wid + (hg35 / 2.0)); + + xp[2] = int(x + dim_.wid + (hg35 / 2.0)); yp[2] = y + int(hg); - pain.lines(xp, yp, 3); + pi.pain.lines(xp, yp, 3, LColor::foreground); break; } - case HUNGARIAN_UMLAUT: // hung. umlaut - { - 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(int(x2), - baseline - lyxfont::ascent(ic, font) - lyxfont::descent('´', font) - (lyxfont::ascent('´', font) + lyxfont::descent('´', font)) / 2, - '´', font); + + case HUNGARIAN_UMLAUT: + drawAccent(pi, x2, baseline, 0x02DD); break; - } - case UMLAUT: // umlaut - { - 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); + + case UMLAUT: + drawAccent(pi, x2, baseline, '"'); break; - } - case CIRCUMFLEX: // circumflex - { - LyXFont tmpf(font); - tmpf.decSize().decSize().decSize(); - 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); + + case CIRCUMFLEX: + drawAccent(pi, x2, baseline, '\x5E'); break; - } - case OGONEK: // ogonek - { + + case OGONEK: { // this does probably not look like an ogonek, so // it should certainly be refined int xp[4], yp[4]; - - xp[0] = int(x2); + + xp[0] = x2; yp[0] = y; - - xp[1] = int(x2); + + xp[1] = x2; yp[1] = y + int(hg35); - + xp[2] = int(x2 - hg35); - yp[2] = y + int(hg / 2.0); - - xp[3] = int(x2 + hg / 4.0); + yp[2] = y + hg / 2; + + xp[3] = x2 + hg / 4; yp[3] = y + int(hg); - pain.lines(xp, yp, 4); + pi.pain.lines(xp, yp, 4, LColor::foreground); break; } + case lSLASH: - case LSLASH: - { + case LSLASH: { int xp[2], yp[2]; - - xp[0] = int(x); - yp[0] = y + int(3.0 * hg); - - xp[1] = int(x + float(wid) * 0.75); + + xp[0] = x; + yp[0] = y + int(3 * hg); + + xp[1] = int(x + dim_.wid * 0.75); yp[1] = y + int(hg); - - pain.lines(xp, yp, 2); - break; + + pi.pain.lines(xp, yp, 2, LColor::foreground); + break; } + case DOT_LESS_I: // dotless-i case DOT_LESS_J: // dotless-j - { // nothing to do for these break; } - } + } else { - pain.fillRectangle(int(x + 1), - 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); + pi.pain.fillRectangle(x + 1, + baseline - dim_.asc + 1, dim_.wid - 2, + dim_.asc + dim_.des - 2, + backgroundColor()); + pi.pain.rectangle(x + 1, baseline - dim_.asc + 1, + dim_.wid - 2, dim_.asc + dim_.des - 2, + LColor::foreground); + docstring dcon(contents.begin(), contents.end()); + pi.pain.text(x + 2, baseline, dcon, font); } - x += width(bv, font); } -void InsetLatexAccent::write(Buffer const *, ostream & os) const +void InsetLatexAccent::write(Buffer const &, ostream & os) const { os << "\\i " << contents << "\n"; } -void InsetLatexAccent::read(Buffer const *, LyXLex & lex) +void InsetLatexAccent::read(Buffer const &, LyXLex & lex) { - lex.EatLine(); - contents = lex.GetString(); + lex.eatLine(); + contents = lex.getString(); checkContents(); } -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 +int InsetLatexAccent::latex(Buffer const &, odocstream & os, + OutputParams const &) const { - os << contents; + os << from_ascii(contents); return 0; } -int InsetLatexAccent::linuxdoc(Buffer const *, ostream & os) const +int InsetLatexAccent::plaintext(Buffer const &, odocstream & os, + OutputParams const &) const { - os << contents; + os << from_ascii(contents); return 0; } -int InsetLatexAccent::docBook(Buffer const *, ostream & os) const +int InsetLatexAccent::docbook(Buffer const &, odocstream & os, + OutputParams const &) const { - os << contents; + // FIXME UNICODE + os << from_ascii(contents); return 0; } -bool InsetLatexAccent::deletable() const +int InsetLatexAccent::textString(Buffer const & buf, odocstream & os, + OutputParams const & op) const { - return true; + return plaintext(buf, os, op); } @@ -667,15 +611,9 @@ bool InsetLatexAccent::directWrite() const } -Inset * InsetLatexAccent::clone(Buffer const &) const +InsetBase::Code InsetLatexAccent::lyxCode() const { - return new InsetLatexAccent(contents); -} - - -Inset::Code InsetLatexAccent::lyxCode() const -{ - return Inset::ACCENT_CODE; + return InsetBase::ACCENT_CODE; } @@ -683,3 +621,6 @@ ostream & operator<<(ostream & o, InsetLatexAccent::ACCENT_TYPES at) { return o << int(at); } + + +} // namespace lyx