From ed7a07e0078d7350554e71d215b6520ce78587a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20P=C3=B6nitz?= Date: Thu, 25 Oct 2007 21:53:06 +0000 Subject: [PATCH] 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 --- src/Makefile.am | 8 -- src/mathed/InsetMathBinom.cpp | 95 ------------ src/mathed/InsetMathBinom.h | 50 ------- src/mathed/InsetMathDFrac.cpp | 78 ---------- src/mathed/InsetMathDFrac.h | 43 ------ src/mathed/InsetMathFrac.cpp | 238 ++++++++++++++++++++++++++++++- src/mathed/InsetMathFrac.h | 89 +++++++++++- src/mathed/InsetMathFracBase.cpp | 49 ------- src/mathed/InsetMathFracBase.h | 36 ----- src/mathed/InsetMathOverset.h | 2 +- src/mathed/InsetMathStackrel.h | 2 +- src/mathed/InsetMathTFrac.cpp | 84 ----------- src/mathed/InsetMathTFrac.h | 43 ------ src/mathed/InsetMathUnderset.h | 2 +- src/mathed/InsetMathXArrow.h | 2 +- src/mathed/MathFactory.cpp | 3 - 16 files changed, 324 insertions(+), 500 deletions(-) delete mode 100644 src/mathed/InsetMathBinom.cpp delete mode 100644 src/mathed/InsetMathBinom.h delete mode 100644 src/mathed/InsetMathDFrac.cpp delete mode 100644 src/mathed/InsetMathDFrac.h delete mode 100644 src/mathed/InsetMathFracBase.cpp delete mode 100644 src/mathed/InsetMathFracBase.h delete mode 100644 src/mathed/InsetMathTFrac.cpp delete mode 100644 src/mathed/InsetMathTFrac.h diff --git a/src/Makefile.am b/src/Makefile.am index 3bd2e29e8a..7fabba5e8e 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/mathed/InsetMathBinom.cpp b/src/mathed/InsetMathBinom.cpp deleted file mode 100644 index 7f4873a474..0000000000 --- a/src/mathed/InsetMathBinom.cpp +++ /dev/null @@ -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 - -#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 diff --git a/src/mathed/InsetMathBinom.h b/src/mathed/InsetMathBinom.h deleted file mode 100644 index 0f89a0706f..0000000000 --- a/src/mathed/InsetMathBinom.h +++ /dev/null @@ -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 diff --git a/src/mathed/InsetMathDFrac.cpp b/src/mathed/InsetMathDFrac.cpp deleted file mode 100644 index e1f7ce727f..0000000000 --- a/src/mathed/InsetMathDFrac.cpp +++ /dev/null @@ -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 - -#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 diff --git a/src/mathed/InsetMathDFrac.h b/src/mathed/InsetMathDFrac.h deleted file mode 100644 index 904212302d..0000000000 --- a/src/mathed/InsetMathDFrac.h +++ /dev/null @@ -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 diff --git a/src/mathed/InsetMathFrac.cpp b/src/mathed/InsetMathFrac.cpp index b2f55f56a2..0b832a83fc 100644 --- a/src/mathed/InsetMathFrac.cpp +++ b/src/mathed/InsetMathFrac.cpp @@ -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 #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 diff --git a/src/mathed/InsetMathFrac.h b/src/mathed/InsetMathFrac.h index 5eb15d193d..b5e99e82d7 100644 --- a/src/mathed/InsetMathFrac.h +++ b/src/mathed/InsetMathFrac.h @@ -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 diff --git a/src/mathed/InsetMathFracBase.cpp b/src/mathed/InsetMathFracBase.cpp deleted file mode 100644 index 1138d6561d..0000000000 --- a/src/mathed/InsetMathFracBase.cpp +++ /dev/null @@ -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 - -#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 diff --git a/src/mathed/InsetMathFracBase.h b/src/mathed/InsetMathFracBase.h deleted file mode 100644 index 88236a0b26..0000000000 --- a/src/mathed/InsetMathFracBase.h +++ /dev/null @@ -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 diff --git a/src/mathed/InsetMathOverset.h b/src/mathed/InsetMathOverset.h index f5ed46c16c..c5e7281885 100644 --- a/src/mathed/InsetMathOverset.h +++ b/src/mathed/InsetMathOverset.h @@ -13,7 +13,7 @@ #define MATH_OVERSETINSET_H -#include "InsetMathFracBase.h" +#include "InsetMathFrac.h" namespace lyx { diff --git a/src/mathed/InsetMathStackrel.h b/src/mathed/InsetMathStackrel.h index af5b44888a..834cc0c4e8 100644 --- a/src/mathed/InsetMathStackrel.h +++ b/src/mathed/InsetMathStackrel.h @@ -12,7 +12,7 @@ #ifndef MATH_STACKRELINSET_H #define MATH_STACKRELINSET_H -#include "InsetMathFracBase.h" +#include "InsetMathFrac.h" namespace lyx { diff --git a/src/mathed/InsetMathTFrac.cpp b/src/mathed/InsetMathTFrac.cpp deleted file mode 100644 index 2a08b20766..0000000000 --- a/src/mathed/InsetMathTFrac.cpp +++ /dev/null @@ -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 - -#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 diff --git a/src/mathed/InsetMathTFrac.h b/src/mathed/InsetMathTFrac.h deleted file mode 100644 index 57ed841b01..0000000000 --- a/src/mathed/InsetMathTFrac.h +++ /dev/null @@ -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 diff --git a/src/mathed/InsetMathUnderset.h b/src/mathed/InsetMathUnderset.h index b28ef012b5..d0a8492439 100644 --- a/src/mathed/InsetMathUnderset.h +++ b/src/mathed/InsetMathUnderset.h @@ -13,7 +13,7 @@ #define MATH_UNDERSETINSET_H -#include "InsetMathFracBase.h" +#include "InsetMathFrac.h" namespace lyx { diff --git a/src/mathed/InsetMathXArrow.h b/src/mathed/InsetMathXArrow.h index a3ebd3b512..a239fd0532 100644 --- a/src/mathed/InsetMathXArrow.h +++ b/src/mathed/InsetMathXArrow.h @@ -12,7 +12,7 @@ #ifndef MATH_XARROWINSET_H #define MATH_XARROWINSET_H -#include "InsetMathFracBase.h" +#include "InsetMathFrac.h" namespace lyx { diff --git a/src/mathed/MathFactory.cpp b/src/mathed/MathFactory.cpp index 2127f65eb8..370c6c6caa 100644 --- a/src/mathed/MathFactory.cpp +++ b/src/mathed/MathFactory.cpp @@ -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" -- 2.39.2