support for \overset

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7594 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-08-22 16:01:13 +00:00
parent 48d6e3a90e
commit cb5af90a1b
7 changed files with 109 additions and 4 deletions

View File

@ -106,6 +106,8 @@ libmathed_la_SOURCES = \
math_nestinset.h \
math_numberinset.C \
math_numberinset.h \
math_oversetinset.C \
math_oversetinset.h \
math_parboxinset.C \
math_parboxinset.h \
math_parinset.C \

View File

@ -31,6 +31,7 @@
#include "math_macrotemplate.h"
#include "math_macroarg.h"
#include "math_makeboxinset.h"
#include "math_oversetinset.h"
#include "math_parboxinset.h"
#include "math_rootinset.h"
#include "math_sizeinset.h"
@ -237,6 +238,8 @@ MathAtom createMathInset(string const & s)
inset << '\'' << endl;
if (inset == "ref")
return MathAtom(new RefInset(l->name));
if (inset == "overset")
return MathAtom(new MathOversetInset);
if (inset == "underset")
return MathAtom(new MathUndersetInset);
if (inset == "decoration")

View File

@ -0,0 +1,63 @@
/**
* \file math_oversetinset.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "math_oversetinset.h"
#include "math_mathmlstream.h"
#include "math_support.h"
using std::max;
using std::auto_ptr;
MathOversetInset::MathOversetInset()
{}
auto_ptr<InsetBase> MathOversetInset::clone() const
{
return auto_ptr<InsetBase>(new MathOversetInset(*this));
}
void MathOversetInset::metrics(MetricsInfo & mi, Dimension & dim) const
{
cell(1).metrics(mi);
FracChanger dummy(mi.base);
cell(0).metrics(mi);
dim_.wid = max(cell(0).width(), cell(1).width()) + 4;
dim_.asc = cell(1).ascent() + cell(0).height() + 4;
dim_.des = cell(1).descent();
dim = dim_;
}
void MathOversetInset::draw(PainterInfo & pi, int x, int y) const
{
int m = x + pi.width / 2;
int yo = y - cell(1).ascent() + cell(0).descent() + 1;
cell(1).draw(pi, m - cell(1).width() / 2, y);
FracChanger dummy(pi.base);
cell(0).draw(pi, m - cell(0).width() / 2, yo);
}
void MathOversetInset::write(WriteStream & os) const
{
os << "\\overset{" << cell(0) << "}{" << cell(1) << '}';
}
void MathOversetInset::normalize(NormalStream & os) const
{
os << "[overset " << cell(0) << ' ' << cell(1) << ']';
}

View File

@ -0,0 +1,36 @@
// -*- C++ -*-
/**
* \file math_oversetinset.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef MATH_OVERSETINSET_H
#define MATH_OVERSETINSET_H
#include "math_fracbase.h"
/// Inset for overset
class MathOversetInset : public MathFracbaseInset {
public:
///
MathOversetInset();
///
virtual std::auto_ptr<InsetBase> clone() const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
void write(WriteStream & os) const;
///
void normalize(NormalStream &) const;
};
#endif

View File

@ -1047,7 +1047,7 @@ int paintRows(BufferView const & bv, LyXText const & text,
int xo, int y, int yf, int yo)
{
lyxerr << " paintRows: rit: " << &*rit << endl;
const_cast<LyXText&>(text).updateRowPositions();
//const_cast<LyXText&>(text).updateRowPositions();
int const yy = yf - y;
int const y2 = bv.painter().paperHeight();

View File

@ -84,12 +84,12 @@ void LyXText::updateRowPositions()
{
ParagraphList::iterator pit = ownerParagraphs().begin();
ParagraphList::iterator end = ownerParagraphs().end();
for (int y = 0; pit != end; ++pit) {
for (height = 0; pit != end; ++pit) {
RowList::iterator rit = pit->rows.begin();
RowList::iterator rend = pit->rows.end();
for ( ; rit != rend ; rit = ++rit) {
rit->y(y);
y += rit->height();
rit->y(height);
height += rit->height();
}
}
}

View File

@ -604,6 +604,7 @@ void LyXText::metrics(MetricsInfo & mi, Dimension & dim)
//anchor_y_ = 0;
redoParagraphs(ownerParagraphs().begin(), ownerParagraphs().end());
updateRowPositions();
// final dimension
dim.asc = firstRow()->ascent_of_text();