#include "insetlatexaccent.h"
#include "debug.h"
-#include "dimension.h"
#include "lyxrc.h"
#include "support/lstrings.h"
#include "BufferView.h"
#include "lyxlex.h"
#include "metricsinfo.h"
+using namespace lyx::support;
+
using std::ostream;
using std::endl;
+using std::auto_ptr;
/* LatexAccent. Proper handling of accented characters */
}
-void InsetLatexAccent::dimension(BufferView *, LyXFont const & font,
- Dimension & dim) const
+void InsetLatexAccent::metrics(MetricsInfo & mi, Dimension & dim) const
{
+ LyXFont & font = mi.base.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
dim.des = font_metrics::maxDescent(font) + 4;
dim.wid = font_metrics::width(contents, font) + 4;
}
+ dim_ = dim;
}
// overhaul. Different ways of drawing (what metrics to use)
// should also be considered.
- BufferView * bv = pi.base.bv;
LyXFont font = pi.base.font;
if (lyxrc.font_norm_type == LyXRC::ISO_10646_1)
font.setLanguage(english_language);
- Dimension dim;
- dimension(bv, font, dim);
-
if (candisp) {
float x2 = x + (rbearing(font) - lbearing(font)) / 2.0;
float hg;
if (plusasc) {
// mark at the top
hg = font_metrics::maxDescent(font);
- y = baseline - dim.asc;
+ y = baseline - dim_.asc;
if (font.shape() == LyXFont::ITALIC_SHAPE)
x2 += (4.0 * hg) / 5.0; // italic
} else {
// at the bottom
- hg = dim.des;
+ hg = dim_.des;
y = baseline;
}
tmpx += int(0.8 * hg); // italic
lyxerr[Debug::KEY] << "Removing dot." << endl;
// remove the dot first
- pi.pain.fillRectangle(x + tmpx, tmpvar, dim.wid,
+ pi.pain.fillRectangle(x + tmpx, tmpvar, dim_.wid,
font_metrics::ascent('i', pi.base.font) -
font_metrics::ascent('x', pi.base.font) - 1,
backgroundColor());
// 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
- int asc = ascent(bv, font); // the dot-less version (here: 'x')
+#warning metrics?
+ int asc = ascent(); // the dot-less version (here: 'x')
ic = tmpic; // set the orig ic back
y = baseline - asc; // update to new y coord.
}
case CIRCLE: // circle
{
- LyXFont tmpf(font);
+ LyXFont tmpf = font;
tmpf.decSize().decSize();
pi.pain.text(int(x2 - (font_metrics::rbearing(0xB0, tmpf) - font_metrics::lbearing(0xB0, tmpf)) / 2.0),
int(baseline - font_metrics::ascent(ic, font) - font_metrics::descent(0xB0, tmpf) - (font_metrics::ascent(0xB0, tmpf) + font_metrics::descent(0xB0, tmpf)) / 3.0),
case SPECIAL_CARON: // special caron
{
switch (ic) {
- case 'L': dim.wid = int(4.0 * dim.wid / 5.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 + dim.wid);
+ xp[0] = int(x + dim_.wid);
yp[0] = int(y + hg35 + hg);
- xp[1] = int(x + dim.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 + dim.wid + (hg35 / 2.0));
+ xp[2] = int(x + dim_.wid + (hg35 / 2.0));
yp[2] = y + int(hg);
pi.pain.lines(xp, yp, 3);
xp[0] = int(x);
yp[0] = y + int(3.0 * hg);
- xp[1] = int(x + float(dim.wid) * 0.75);
+ xp[1] = int(x + float(dim_.wid) * 0.75);
yp[1] = y + int(hg);
pi.pain.lines(xp, yp, 2);
}
} else {
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);
+ 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);
pi.pain.text(x + 2, baseline, contents, font);
}
}
}
-Inset * InsetLatexAccent::clone(Buffer const &) const
+auto_ptr<InsetBase> InsetLatexAccent::clone() const
{
- return new InsetLatexAccent(contents);
+ return auto_ptr<InsetBase>(new InsetLatexAccent(contents));
}
-// Inset * InsetLatexAccent::clone(Buffer const &, bool) const
-// {
-// return new InsetLatexAccent(contents);
-// }
-
-
-Inset::Code InsetLatexAccent::lyxCode() const
+InsetOld::Code InsetLatexAccent::lyxCode() const
{
- return Inset::ACCENT_CODE;
+ return InsetOld::ACCENT_CODE;
}