mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-27 03:36:39 +00:00
put \frac style stuff into a single unit. -161477.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21208 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
dc45268132
commit
ed7a07e007
@ -316,8 +316,6 @@ liblyxmathed_la_SOURCES = \
|
||||
mathed/InsetMathArray.h \
|
||||
mathed/InsetMathBig.cpp \
|
||||
mathed/InsetMathBig.h \
|
||||
mathed/InsetMathBinom.cpp \
|
||||
mathed/InsetMathBinom.h \
|
||||
mathed/InsetMathBoldSymbol.cpp \
|
||||
mathed/InsetMathBoldSymbol.h \
|
||||
mathed/InsetMathBox.cpp \
|
||||
@ -341,8 +339,6 @@ liblyxmathed_la_SOURCES = \
|
||||
mathed/InsetMathDecoration.h \
|
||||
mathed/InsetMathDelim.cpp \
|
||||
mathed/InsetMathDelim.h \
|
||||
mathed/InsetMathDFrac.cpp \
|
||||
mathed/InsetMathDFrac.h \
|
||||
mathed/InsetMathDiff.cpp \
|
||||
mathed/InsetMathDiff.h \
|
||||
mathed/InsetMathDots.cpp \
|
||||
@ -359,8 +355,6 @@ liblyxmathed_la_SOURCES = \
|
||||
mathed/InsetMathFont.h \
|
||||
mathed/InsetMathFontOld.cpp \
|
||||
mathed/InsetMathFontOld.h \
|
||||
mathed/InsetMathFracBase.cpp \
|
||||
mathed/InsetMathFracBase.h \
|
||||
mathed/InsetMathFrac.cpp \
|
||||
mathed/InsetMathFrac.h \
|
||||
mathed/InsetMathFrameBox.cpp \
|
||||
@ -416,8 +410,6 @@ liblyxmathed_la_SOURCES = \
|
||||
mathed/InsetMathSymbol.h \
|
||||
mathed/InsetMathTabular.cpp \
|
||||
mathed/InsetMathTabular.h \
|
||||
mathed/InsetMathTFrac.cpp \
|
||||
mathed/InsetMathTFrac.h \
|
||||
mathed/InsetMathUnderset.cpp \
|
||||
mathed/InsetMathUnderset.h \
|
||||
mathed/InsetMathUnknown.cpp \
|
||||
|
@ -1,95 +0,0 @@
|
||||
/**
|
||||
* \file InsetMathBinom.cpp
|
||||
* 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 "InsetMathBinom.h"
|
||||
#include "MathData.h"
|
||||
#include "MathSupport.h"
|
||||
#include "MathStream.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
InsetMathBinom::InsetMathBinom(bool choose)
|
||||
: choose_(choose)
|
||||
{}
|
||||
|
||||
|
||||
Inset * InsetMathBinom::clone() const
|
||||
{
|
||||
return new InsetMathBinom(*this);
|
||||
}
|
||||
|
||||
|
||||
int InsetMathBinom::dw(int height) const
|
||||
{
|
||||
int w = height / 5;
|
||||
if (w > 15)
|
||||
w = 15;
|
||||
if (w < 6)
|
||||
w = 6;
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
ScriptChanger dummy(mi.base);
|
||||
Dimension dim0, dim1;
|
||||
cell(0).metrics(mi, dim0);
|
||||
cell(1).metrics(mi, dim1);
|
||||
dim.asc = dim0.height() + 4 + 5;
|
||||
dim.des = dim1.height() + 4 - 5;
|
||||
dim.wid = std::max(dim0.width(), dim1.wid) + 2 * dw(dim.height()) + 4;
|
||||
metricsMarkers2(dim);
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathBinom::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
|
||||
Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
|
||||
int m = x + dim.width() / 2;
|
||||
ScriptChanger dummy(pi.base);
|
||||
cell(0).draw(pi, m - dim0.width() / 2, y - dim0.des - 3 - 5);
|
||||
cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 3 - 5);
|
||||
mathed_draw_deco(pi, x, y - dim.ascent(), dw(dim.height()), dim.height(), from_ascii("("));
|
||||
mathed_draw_deco(pi, x + dim.width() - dw(dim.height()), y - dim.ascent(),
|
||||
dw(dim.height()), dim.height(), from_ascii(")"));
|
||||
drawMarkers2(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
bool InsetMathBinom::extraBraces() const
|
||||
{
|
||||
return choose_;
|
||||
}
|
||||
|
||||
|
||||
void InsetMathBinom::write(WriteStream & os) const
|
||||
{
|
||||
if (choose_)
|
||||
os << '{' << cell(0) << " \\choose " << cell(1) << '}';
|
||||
else
|
||||
os << "\\binom{" << cell(0) << "}{" << cell(1) << '}';
|
||||
}
|
||||
|
||||
|
||||
void InsetMathBinom::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[binom " << cell(0) << ' ' << cell(1) << ']';
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
@ -1,50 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file InsetMathBinom.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_BINOMINSET_H
|
||||
#define MATH_BINOMINSET_H
|
||||
|
||||
#include "InsetMathFracBase.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
|
||||
/// Binom like objects
|
||||
class InsetMathBinom : public InsetMathFracBase {
|
||||
public:
|
||||
///
|
||||
explicit InsetMathBinom(bool choose = false);
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
///
|
||||
void normalize(NormalStream &) const;
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo &, int x, int y) const;
|
||||
/// draw decorations.
|
||||
void drawDecoration(PainterInfo & pi, int x, int y) const
|
||||
{ drawMarkers2(pi, x, y); }
|
||||
///
|
||||
bool extraBraces() const;
|
||||
private:
|
||||
virtual Inset * clone() const;
|
||||
///
|
||||
int dw(int height) const;
|
||||
///
|
||||
bool choose_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
@ -1,78 +0,0 @@
|
||||
/**
|
||||
* \file InsetMathDFrac.cpp
|
||||
* 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 "InsetMathDFrac.h"
|
||||
#include "MathData.h"
|
||||
#include "MathStream.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
InsetMathDFrac::InsetMathDFrac()
|
||||
: InsetMathFrac()
|
||||
{}
|
||||
|
||||
|
||||
Inset * InsetMathDFrac::clone() const
|
||||
{
|
||||
return new InsetMathDFrac(*this);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathDFrac::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
Dimension dim0, dim1;
|
||||
cell(0).metrics(mi, dim0);
|
||||
cell(1).metrics(mi, dim1);
|
||||
dim.wid = std::max(dim0.wid, dim1.wid) + 2;
|
||||
dim.asc = dim0.height() + 2 + 5;
|
||||
dim.des = dim1.height() + 2 - 5;
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathDFrac::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
|
||||
Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
|
||||
int m = x + dim.wid / 2;
|
||||
cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
|
||||
cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5);
|
||||
pi.pain.line(x + 1, y - 5, x + dim.wid - 2, y - 5, Color_math);
|
||||
setPosCache(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
docstring InsetMathDFrac::name() const
|
||||
{
|
||||
return from_ascii("dfrac");
|
||||
}
|
||||
|
||||
|
||||
void InsetMathDFrac::mathmlize(MathStream & os) const
|
||||
{
|
||||
os << MTag("mdfrac") << cell(0) << cell(1) << ETag("mdfrac");
|
||||
}
|
||||
|
||||
|
||||
void InsetMathDFrac::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
features.require("amsmath");
|
||||
InsetMathNest::validate(features);
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
@ -1,43 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file InsetMathFrac.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_DFRACINSET_H
|
||||
#define MATH_DFRACINSET_H
|
||||
|
||||
#include "InsetMathFrac.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
|
||||
/// \dfrac support
|
||||
class InsetMathDFrac : public InsetMathFrac {
|
||||
public:
|
||||
///
|
||||
InsetMathDFrac();
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo &, int x, int y) const;
|
||||
///
|
||||
docstring name() const;
|
||||
///
|
||||
void mathmlize(MathStream &) const;
|
||||
///
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
private:
|
||||
virtual Inset * clone() const;
|
||||
};
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* \file InsetMathFrac.cpp
|
||||
* \file InsetMathFracBase.cpp
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
@ -12,16 +12,50 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "InsetMathFrac.h"
|
||||
|
||||
#include "Cursor.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "MathData.h"
|
||||
#include "MathStream.h"
|
||||
#include "MathSupport.h"
|
||||
#include "TextPainter.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "Cursor.h"
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InsetMathFracBase
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
InsetMathFracBase::InsetMathFracBase(idx_type ncells)
|
||||
: InsetMathNest(ncells)
|
||||
{}
|
||||
|
||||
|
||||
bool InsetMathFracBase::idxUpDown(Cursor & cur, bool up) const
|
||||
{
|
||||
InsetMath::idx_type target = !up; // up ? 0 : 1, since upper cell has idx 0
|
||||
if (cur.idx() == target)
|
||||
return false;
|
||||
cur.idx() = target;
|
||||
cur.pos() = cell(target).x2pos(cur.x_target());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InsetMathFrac
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
InsetMathFrac::InsetMathFrac(Kind kind, InsetMath::idx_type ncells)
|
||||
: InsetMathFracBase(ncells), kind_(kind)
|
||||
{}
|
||||
@ -316,5 +350,203 @@ void InsetMathFrac::validate(LaTeXFeatures & features) const
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InsetMathDFrac
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Inset * InsetMathDFrac::clone() const
|
||||
{
|
||||
return new InsetMathDFrac(*this);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathDFrac::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
Dimension dim0, dim1;
|
||||
cell(0).metrics(mi, dim0);
|
||||
cell(1).metrics(mi, dim1);
|
||||
dim.wid = std::max(dim0.wid, dim1.wid) + 2;
|
||||
dim.asc = dim0.height() + 2 + 5;
|
||||
dim.des = dim1.height() + 2 - 5;
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathDFrac::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
|
||||
Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
|
||||
int m = x + dim.wid / 2;
|
||||
cell(0).draw(pi, m - dim0.wid / 2, y - dim0.des - 2 - 5);
|
||||
cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 2 - 5);
|
||||
pi.pain.line(x + 1, y - 5, x + dim.wid - 2, y - 5, Color_math);
|
||||
setPosCache(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
docstring InsetMathDFrac::name() const
|
||||
{
|
||||
return from_ascii("dfrac");
|
||||
}
|
||||
|
||||
|
||||
void InsetMathDFrac::mathmlize(MathStream & os) const
|
||||
{
|
||||
os << MTag("mdfrac") << cell(0) << cell(1) << ETag("mdfrac");
|
||||
}
|
||||
|
||||
|
||||
void InsetMathDFrac::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
features.require("amsmath");
|
||||
InsetMathNest::validate(features);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InsetMathTFrac
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
Inset * InsetMathTFrac::clone() const
|
||||
{
|
||||
return new InsetMathTFrac(*this);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathTFrac::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
StyleChanger dummy(mi.base, LM_ST_SCRIPT);
|
||||
Dimension dim0;
|
||||
cell(0).metrics(mi, dim0);
|
||||
Dimension dim1;
|
||||
cell(1).metrics(mi, dim1);
|
||||
dim.wid = std::max(dim0.width(), dim1.width()) + 2;
|
||||
dim.asc = dim0.height() + 2 + 5;
|
||||
dim.des = dim1.height() + 2 - 5;
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathTFrac::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
StyleChanger dummy(pi.base, LM_ST_SCRIPT);
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
|
||||
Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
|
||||
int m = x + dim.wid / 2;
|
||||
cell(0).draw(pi, m - dim0.width() / 2, y - dim0.descent() - 2 - 5);
|
||||
cell(1).draw(pi, m - dim1.width() / 2, y + dim1.ascent() + 2 - 5);
|
||||
pi.pain.line(x + 1, y - 5, x + dim.wid - 2, y - 5, Color_math);
|
||||
setPosCache(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
docstring InsetMathTFrac::name() const
|
||||
{
|
||||
return from_ascii("tfrac");
|
||||
}
|
||||
|
||||
|
||||
void InsetMathTFrac::mathmlize(MathStream & os) const
|
||||
{
|
||||
os << MTag("mtfrac") << cell(0) << cell(1) << ETag("mtfrac");
|
||||
}
|
||||
|
||||
|
||||
void InsetMathTFrac::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
features.require("amsmath");
|
||||
InsetMathNest::validate(features);
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// InsetMathBinom
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
InsetMathBinom::InsetMathBinom(bool choose)
|
||||
: choose_(choose)
|
||||
{}
|
||||
|
||||
|
||||
Inset * InsetMathBinom::clone() const
|
||||
{
|
||||
return new InsetMathBinom(*this);
|
||||
}
|
||||
|
||||
|
||||
int InsetMathBinom::dw(int height) const
|
||||
{
|
||||
int w = height / 5;
|
||||
if (w > 15)
|
||||
w = 15;
|
||||
if (w < 6)
|
||||
w = 6;
|
||||
return w;
|
||||
}
|
||||
|
||||
|
||||
void InsetMathBinom::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
ScriptChanger dummy(mi.base);
|
||||
Dimension dim0, dim1;
|
||||
cell(0).metrics(mi, dim0);
|
||||
cell(1).metrics(mi, dim1);
|
||||
dim.asc = dim0.height() + 4 + 5;
|
||||
dim.des = dim1.height() + 4 - 5;
|
||||
dim.wid = std::max(dim0.width(), dim1.wid) + 2 * dw(dim.height()) + 4;
|
||||
metricsMarkers2(dim);
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathBinom::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
|
||||
Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
|
||||
int m = x + dim.width() / 2;
|
||||
ScriptChanger dummy(pi.base);
|
||||
cell(0).draw(pi, m - dim0.width() / 2, y - dim0.des - 3 - 5);
|
||||
cell(1).draw(pi, m - dim1.wid / 2, y + dim1.asc + 3 - 5);
|
||||
mathed_draw_deco(pi, x, y - dim.ascent(), dw(dim.height()), dim.height(), from_ascii("("));
|
||||
mathed_draw_deco(pi, x + dim.width() - dw(dim.height()), y - dim.ascent(),
|
||||
dw(dim.height()), dim.height(), from_ascii(")"));
|
||||
drawMarkers2(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
bool InsetMathBinom::extraBraces() const
|
||||
{
|
||||
return choose_;
|
||||
}
|
||||
|
||||
|
||||
void InsetMathBinom::write(WriteStream & os) const
|
||||
{
|
||||
if (choose_)
|
||||
os << '{' << cell(0) << " \\choose " << cell(1) << '}';
|
||||
else
|
||||
os << "\\binom{" << cell(0) << "}{" << cell(1) << '}';
|
||||
}
|
||||
|
||||
|
||||
void InsetMathBinom::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[binom " << cell(0) << ' ' << cell(1) << ']';
|
||||
}
|
||||
|
||||
} // namespace lyx
|
||||
|
@ -10,15 +10,29 @@
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef MATH_FRACINSET_H
|
||||
#define MATH_FRACINSET_H
|
||||
#ifndef MATH_FRAC_H
|
||||
#define MATH_FRAC_H
|
||||
|
||||
#include "InsetMathFracBase.h"
|
||||
#include "InsetMathNest.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
|
||||
class InsetMathFracBase : public InsetMathNest {
|
||||
public:
|
||||
///
|
||||
explicit InsetMathFracBase(idx_type ncells = 2);
|
||||
///
|
||||
bool idxUpDown(Cursor &, bool up) const;
|
||||
///
|
||||
bool idxLeft(Cursor &) const { return false; }
|
||||
///
|
||||
bool idxRight(Cursor &) const { return false; }
|
||||
};
|
||||
|
||||
|
||||
|
||||
/// Fraction like objects (frac, binom)
|
||||
class InsetMathFrac : public InsetMathFracBase {
|
||||
public:
|
||||
@ -68,12 +82,79 @@ public:
|
||||
///
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
public:
|
||||
virtual Inset * clone() const;
|
||||
Inset * clone() const;
|
||||
///
|
||||
Kind kind_;
|
||||
};
|
||||
|
||||
|
||||
/// \dfrac support
|
||||
class InsetMathDFrac : public InsetMathFrac {
|
||||
public:
|
||||
///
|
||||
InsetMathDFrac() {}
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo &, int x, int y) const;
|
||||
///
|
||||
docstring name() const;
|
||||
///
|
||||
void mathmlize(MathStream &) const;
|
||||
///
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
private:
|
||||
Inset * clone() const;
|
||||
};
|
||||
|
||||
|
||||
/// \tfrac support
|
||||
class InsetMathTFrac : public InsetMathFrac {
|
||||
public:
|
||||
///
|
||||
InsetMathTFrac() {}
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo &, int x, int y) const;
|
||||
///
|
||||
docstring name() const;
|
||||
///
|
||||
void mathmlize(MathStream &) const;
|
||||
///
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
private:
|
||||
Inset * clone() const;
|
||||
};
|
||||
|
||||
|
||||
/// Binom like objects
|
||||
class InsetMathBinom : public InsetMathFracBase {
|
||||
public:
|
||||
///
|
||||
explicit InsetMathBinom(bool choose = false);
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
///
|
||||
void normalize(NormalStream &) const;
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo &, int x, int y) const;
|
||||
/// draw decorations.
|
||||
void drawDecoration(PainterInfo & pi, int x, int y) const
|
||||
{ drawMarkers2(pi, x, y); }
|
||||
///
|
||||
bool extraBraces() const;
|
||||
private:
|
||||
Inset * clone() const;
|
||||
///
|
||||
int dw(int height) const;
|
||||
///
|
||||
bool choose_;
|
||||
};
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
|
||||
#endif
|
||||
|
@ -1,49 +0,0 @@
|
||||
/**
|
||||
* \file InsetMathFracBase.cpp
|
||||
* 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 "InsetMathFracBase.h"
|
||||
#include "MathData.h"
|
||||
#include "Cursor.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
|
||||
InsetMathFracBase::InsetMathFracBase(idx_type ncells)
|
||||
: InsetMathNest(ncells)
|
||||
{}
|
||||
|
||||
|
||||
bool InsetMathFracBase::idxRight(Cursor &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool InsetMathFracBase::idxLeft(Cursor &) const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool InsetMathFracBase::idxUpDown(Cursor & cur, bool up) const
|
||||
{
|
||||
InsetMath::idx_type target = !up; // up ? 0 : 1, since upper cell has idx 0
|
||||
if (cur.idx() == target)
|
||||
return false;
|
||||
cur.idx() = target;
|
||||
cur.pos() = cell(target).x2pos(cur.x_target());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
@ -1,36 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file InsetMathFracBase.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_FRACBASE_H
|
||||
#define MATH_FRACBASE_H
|
||||
|
||||
#include "InsetMathNest.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
|
||||
class InsetMathFracBase : public InsetMathNest {
|
||||
public:
|
||||
///
|
||||
explicit InsetMathFracBase(idx_type ncells = 2);
|
||||
///
|
||||
bool idxUpDown(Cursor &, bool up) const;
|
||||
///
|
||||
bool idxLeft(Cursor &) const;
|
||||
///
|
||||
bool idxRight(Cursor &) const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
#endif
|
@ -13,7 +13,7 @@
|
||||
#define MATH_OVERSETINSET_H
|
||||
|
||||
|
||||
#include "InsetMathFracBase.h"
|
||||
#include "InsetMathFrac.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef MATH_STACKRELINSET_H
|
||||
#define MATH_STACKRELINSET_H
|
||||
|
||||
#include "InsetMathFracBase.h"
|
||||
#include "InsetMathFrac.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
@ -1,84 +0,0 @@
|
||||
/**
|
||||
* \file InsetMathDFrac.cpp
|
||||
* 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 "InsetMathTFrac.h"
|
||||
|
||||
#include "MathData.h"
|
||||
#include "MathStream.h"
|
||||
|
||||
#include "LaTeXFeatures.h"
|
||||
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
InsetMathTFrac::InsetMathTFrac()
|
||||
: InsetMathFrac()
|
||||
{}
|
||||
|
||||
|
||||
Inset * InsetMathTFrac::clone() const
|
||||
{
|
||||
return new InsetMathTFrac(*this);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathTFrac::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
StyleChanger dummy(mi.base, LM_ST_SCRIPT);
|
||||
Dimension dim0;
|
||||
cell(0).metrics(mi, dim0);
|
||||
Dimension dim1;
|
||||
cell(1).metrics(mi, dim1);
|
||||
dim.wid = std::max(dim0.width(), dim1.width()) + 2;
|
||||
dim.asc = dim0.height() + 2 + 5;
|
||||
dim.des = dim1.height() + 2 - 5;
|
||||
// Cache the inset dimension.
|
||||
setDimCache(mi, dim);
|
||||
}
|
||||
|
||||
|
||||
void InsetMathTFrac::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
StyleChanger dummy(pi.base, LM_ST_SCRIPT);
|
||||
Dimension const dim = dimension(*pi.base.bv);
|
||||
Dimension const & dim0 = cell(0).dimension(*pi.base.bv);
|
||||
Dimension const & dim1 = cell(1).dimension(*pi.base.bv);
|
||||
int m = x + dim.wid / 2;
|
||||
cell(0).draw(pi, m - dim0.width() / 2, y - dim0.descent() - 2 - 5);
|
||||
cell(1).draw(pi, m - dim1.width() / 2, y + dim1.ascent() + 2 - 5);
|
||||
pi.pain.line(x + 1, y - 5, x + dim.wid - 2, y - 5, Color_math);
|
||||
setPosCache(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
docstring InsetMathTFrac::name() const
|
||||
{
|
||||
return from_ascii("tfrac");
|
||||
}
|
||||
|
||||
|
||||
void InsetMathTFrac::mathmlize(MathStream & os) const
|
||||
{
|
||||
os << MTag("mtfrac") << cell(0) << cell(1) << ETag("mtfrac");
|
||||
}
|
||||
|
||||
|
||||
void InsetMathTFrac::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
features.require("amsmath");
|
||||
InsetMathNest::validate(features);
|
||||
}
|
||||
|
||||
|
||||
} // namespace lyx
|
@ -1,43 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file InsetMathTFrac.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_TFRACINSET_H
|
||||
#define MATH_TFRACINSET_H
|
||||
|
||||
#include "InsetMathFrac.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
||||
|
||||
/// \dfrac support
|
||||
class InsetMathTFrac : public InsetMathFrac {
|
||||
public:
|
||||
///
|
||||
InsetMathTFrac();
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo &, int x, int y) const;
|
||||
///
|
||||
docstring name() const;
|
||||
///
|
||||
void mathmlize(MathStream &) const;
|
||||
///
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
private:
|
||||
virtual Inset * clone() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
} // namespace lyx
|
||||
#endif
|
@ -13,7 +13,7 @@
|
||||
#define MATH_UNDERSETINSET_H
|
||||
|
||||
|
||||
#include "InsetMathFracBase.h"
|
||||
#include "InsetMathFrac.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#ifndef MATH_XARROWINSET_H
|
||||
#define MATH_XARROWINSET_H
|
||||
|
||||
#include "InsetMathFracBase.h"
|
||||
#include "InsetMathFrac.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
|
@ -14,14 +14,12 @@
|
||||
|
||||
#include "InsetMathAMSArray.h"
|
||||
#include "InsetMathArray.h"
|
||||
#include "InsetMathBinom.h"
|
||||
#include "InsetMathBoldSymbol.h"
|
||||
#include "InsetMathBoxed.h"
|
||||
#include "InsetMathBox.h"
|
||||
#include "InsetMathCases.h"
|
||||
#include "InsetMathColor.h"
|
||||
#include "InsetMathDecoration.h"
|
||||
#include "InsetMathDFrac.h"
|
||||
#include "InsetMathDots.h"
|
||||
#include "InsetMathFBox.h"
|
||||
#include "InsetMathFont.h"
|
||||
@ -44,7 +42,6 @@
|
||||
#include "InsetMathSubstack.h"
|
||||
#include "InsetMathSymbol.h"
|
||||
#include "InsetMathTabular.h"
|
||||
#include "InsetMathTFrac.h"
|
||||
#include "InsetMathUnderset.h"
|
||||
#include "InsetMathUnknown.h"
|
||||
#include "InsetMathXArrow.h"
|
||||
|
Loading…
Reference in New Issue
Block a user