From: André Pönitz Date: Tue, 6 Nov 2007 20:57:29 +0000 (+0000) Subject: some consolidation X-Git-Tag: 1.6.10~7450 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8995e86584837353490ea1f707b9b77e351fbe17;p=features.git some consolidation git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@21478 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/Makefile.am b/src/Makefile.am index 0ec29dfbc9..a5ecd478a4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -322,8 +322,6 @@ liblyxmathed_la_SOURCES = \ mathed/InsetMathBoldSymbol.cpp \ mathed/InsetMathBoldSymbol.h \ mathed/InsetMathBox.cpp \ - mathed/InsetMathBoxed.cpp \ - mathed/InsetMathBoxed.h \ mathed/InsetMathBox.h \ mathed/InsetMathBrace.cpp \ mathed/InsetMathBrace.h \ @@ -352,16 +350,12 @@ liblyxmathed_la_SOURCES = \ mathed/InsetMathExFunc.h \ mathed/InsetMathExInt.cpp \ mathed/InsetMathExInt.h \ - mathed/InsetMathFBox.cpp \ - mathed/InsetMathFBox.h \ mathed/InsetMathFont.cpp \ mathed/InsetMathFont.h \ mathed/InsetMathFontOld.cpp \ mathed/InsetMathFontOld.h \ mathed/InsetMathFrac.cpp \ mathed/InsetMathFrac.h \ - mathed/InsetMathFrameBox.cpp \ - mathed/InsetMathFrameBox.h \ mathed/InsetMathGrid.cpp \ mathed/InsetMathGrid.h \ mathed/InsetMath.h \ @@ -375,8 +369,6 @@ liblyxmathed_la_SOURCES = \ mathed/InsetMathLim.h \ mathed/MathMacro.cpp \ mathed/MathMacro.h \ - mathed/InsetMathMakebox.cpp \ - mathed/InsetMathMakebox.h \ mathed/InsetMathMatrix.cpp \ mathed/InsetMathMatrix.h \ mathed/InsetMathNest.cpp \ @@ -447,8 +439,6 @@ liblyxmathed_la_SOURCES = \ mathed/MathSupport.h \ mathed/TextPainter.cpp \ mathed/TextPainter.h -# mathed/InsetMathMBox.cpp -# mathed/InsetMathMBox.h ############################### Insets ############################## diff --git a/src/mathed/InsetMathBox.cpp b/src/mathed/InsetMathBox.cpp index 3056c72dbc..013e35bd93 100644 --- a/src/mathed/InsetMathBox.cpp +++ b/src/mathed/InsetMathBox.cpp @@ -4,6 +4,7 @@ * Licence details can be found in the file COPYING. * * \author André Pönitz + * \author Ling Li (InsetMathMakebox) * * Full author contact details are available in file CREDITS. */ @@ -12,26 +13,30 @@ #include "InsetMathBox.h" +#include "LaTeXFeatures.h" #include "MathData.h" #include "MathStream.h" +#include "MathSupport.h" #include "MetricsInfo.h" +#include "frontends/Painter.h" + #include namespace lyx { +///////////////////////////////////////////////////////////////////// +// +// InsetMathBox +// +///////////////////////////////////////////////////////////////////// + InsetMathBox::InsetMathBox(docstring const & name) : InsetMathNest(1), name_(name) {} -Inset * InsetMathBox::clone() const -{ - return new InsetMathBox(*this); -} - - void InsetMathBox::write(WriteStream & os) const { os << '\\' << name_ << '{' << cell(0) << '}'; @@ -70,4 +75,255 @@ void InsetMathBox::infoize(odocstream & os) const } + +///////////////////////////////////////////////////////////////////// +// +// InsetMathFBox +// +///////////////////////////////////////////////////////////////////// + + +InsetMathFBox::InsetMathFBox() + : InsetMathNest(1) +{} + + +void InsetMathFBox::metrics(MetricsInfo & mi, Dimension & dim) const +{ + FontSetChanger dummy(mi.base, "textnormal"); + cell(0).metrics(mi, dim); + metricsMarkers(dim, 3); // 1 pixel space, 1 frame, 1 space + // Cache the inset dimension. + setDimCache(mi, dim); +} + + +void InsetMathFBox::draw(PainterInfo & pi, int x, int y) const +{ + Dimension const dim = dimension(*pi.base.bv); + pi.pain.rectangle(x + 1, y - dim.ascent() + 1, + dim.width() - 2, dim.height() - 2, Color_foreground); + FontSetChanger dummy(pi.base, "textnormal"); + cell(0).draw(pi, x + 3, y); + setPosCache(pi, x, y); +} + + +void InsetMathFBox::write(WriteStream & os) const +{ + os << "\\fbox{" << cell(0) << '}'; +} + + +void InsetMathFBox::normalize(NormalStream & os) const +{ + os << "[fbox " << cell(0) << ']'; +} + + +void InsetMathFBox::infoize(odocstream & os) const +{ + os << "FBox: "; +} + + +///////////////////////////////////////////////////////////////////// +// +// InsetMathFrameBox +// +///////////////////////////////////////////////////////////////////// + + +InsetMathFrameBox::InsetMathFrameBox() + : InsetMathNest(3) +{} + + +void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const +{ + FontSetChanger dummy(mi.base, "textnormal"); + w_ = mathed_char_width(mi.base.font, '['); + InsetMathNest::metrics(mi); + dim = cell(0).dimension(*mi.base.bv); + dim += cell(1).dimension(*mi.base.bv); + dim += cell(2).dimension(*mi.base.bv); + metricsMarkers(dim); + // Cache the inset dimension. + setDimCache(mi, dim); +} + + +void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const +{ + FontSetChanger dummy(pi.base, "textnormal"); + Dimension const dim = dimension(*pi.base.bv); + pi.pain.rectangle(x + 1, y - dim.ascent() + 1, + dim.width() - 2, dim.height() - 2, Color_foreground); + x += 5; + BufferView const & bv = *pi.base.bv; + + drawStrBlack(pi, x, y, from_ascii("[")); + x += w_; + cell(0).draw(pi, x, y); + x += cell(0).dimension(bv).wid; + drawStrBlack(pi, x, y, from_ascii("]")); + x += w_ + 4; + + drawStrBlack(pi, x, y, from_ascii("[")); + x += w_; + cell(1).draw(pi, x, y); + x += cell(1).dimension(bv).wid; + drawStrBlack(pi, x, y, from_ascii("]")); + x += w_ + 4; + + cell(2).draw(pi, x, y); + drawMarkers(pi, x, y); +} + + +void InsetMathFrameBox::write(WriteStream & os) const +{ + os << "\\framebox"; + os << '[' << cell(0) << ']'; + if (cell(1).size()) + os << '[' << cell(1) << ']'; + os << '{' << cell(2) << '}'; +} + + +void InsetMathFrameBox::normalize(NormalStream & os) const +{ + os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']'; +} + + + +///////////////////////////////////////////////////////////////////// +// +// InsetMathBoxed +// +///////////////////////////////////////////////////////////////////// + +InsetMathBoxed::InsetMathBoxed() + : InsetMathNest(1) +{} + + +void InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const +{ + cell(0).metrics(mi, dim); + metricsMarkers2(dim, 3); // 1 pixel space, 1 frame, 1 space + // Cache the inset dimension. + setDimCache(mi, dim); +} + + +void InsetMathBoxed::draw(PainterInfo & pi, int x, int y) const +{ + Dimension const dim = dimension(*pi.base.bv); + pi.pain.rectangle(x + 1, y - dim.ascent() + 1, + dim.width() - 2, dim.height() - 2, Color_foreground); + cell(0).draw(pi, x + 3, y); + setPosCache(pi, x, y); +} + + +void InsetMathBoxed::write(WriteStream & os) const +{ + os << "\\boxed{" << cell(0) << '}'; +} + + +void InsetMathBoxed::normalize(NormalStream & os) const +{ + os << "[boxed " << cell(0) << ']'; +} + + +void InsetMathBoxed::infoize(odocstream & os) const +{ + os << "Boxed: "; +} + + +void InsetMathBoxed::validate(LaTeXFeatures & features) const +{ + features.require("amsmath"); +} + + +///////////////////////////////////////////////////////////////////// +// +// InsetMathMakebox +// +///////////////////////////////////////////////////////////////////// + + +InsetMathMakebox::InsetMathMakebox() + : InsetMathNest(3) +{} + + +void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const +{ + FontSetChanger dummy(mi.base, from_ascii("textnormal")); + w_ = mathed_char_width(mi.base.font, '['); + InsetMathNest::metrics(mi); + dim = cell(0).dimension(*mi.base.bv); + dim += cell(1).dimension(*mi.base.bv); + dim += cell(2).dimension(*mi.base.bv); + dim.wid += 4 * w_ + 4; + metricsMarkers(dim); + // Cache the inset dimension. + setDimCache(mi, dim); +} + + +void InsetMathMakebox::draw(PainterInfo & pi, int x, int y) const +{ + FontSetChanger dummy(pi.base, from_ascii("textnormal")); + drawMarkers(pi, x, y); + + drawStrBlack(pi, x, y, from_ascii("[")); + x += w_; + cell(0).draw(pi, x, y); + x += cell(0).dimension(*pi.base.bv).width(); + drawStrBlack(pi, x, y, from_ascii("]")); + x += w_ + 2; + + drawStrBlack(pi, x, y, from_ascii("[")); + x += w_; + cell(1).draw(pi, x, y); + x += cell(1).dimension(*pi.base.bv).wid; + drawStrBlack(pi, x, y, from_ascii("]")); + x += w_ + 2; + + cell(2).draw(pi, x, y); + setPosCache(pi, x, y); +} + + +void InsetMathMakebox::write(WriteStream & os) const +{ + os << "\\makebox"; + os << '[' << cell(0) << ']'; + if (cell(1).size()) + os << '[' << cell(1) << ']'; + os << '{' << cell(2) << '}'; +} + + +void InsetMathMakebox::normalize(NormalStream & os) const +{ + os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']'; +} + + +void InsetMathMakebox::infoize(odocstream & os) const +{ + os << "Makebox (width: " << cell(0) + << " pos: " << cell(1) << ")"; +} + + } // namespace lyx diff --git a/src/mathed/InsetMathBox.h b/src/mathed/InsetMathBox.h index c27aa3d0a2..9b40ba0951 100644 --- a/src/mathed/InsetMathBox.h +++ b/src/mathed/InsetMathBox.h @@ -19,11 +19,7 @@ namespace lyx { - -class Font; - /// Support for \\mbox - class InsetMathBox : public InsetMathNest { public: /// @@ -42,13 +38,105 @@ public: void infoize(odocstream & os) const; private: - virtual Inset * clone() const; + Inset * clone() const { return new InsetMathBox(*this); } /// docstring name_; }; +/// Non-AMS-style frame +class InsetMathFBox : public InsetMathNest { +public: + /// + InsetMathFBox(); + /// + mode_type currentMode() const { return TEXT_MODE; } + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo & pi, int x, int y) const; + /// + void write(WriteStream & os) const; + /// write normalized content + void normalize(NormalStream & ns) const; + /// + void infoize(odocstream & os) const; +private: + /// + Inset * clone() const { return new InsetMathFBox(*this); } +}; + + +/// Extra nesting +class InsetMathFrameBox : public InsetMathNest { +public: + /// + InsetMathFrameBox(); + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo & pi, int x, int y) const; + /// + void write(WriteStream & os) const; + /// write normalized content + void normalize(NormalStream & ns) const; + /// + mode_type currentMode() const { return TEXT_MODE; } +private: + Inset * clone() const { return new InsetMathFrameBox(*this); } + /// width of '[' in current font + mutable int w_; +}; + + +/// Extra nesting: \\makebox. +// consolidate with InsetMathFrameBox? +class InsetMathMakebox : public InsetMathNest { +public: + /// + InsetMathMakebox(); + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo & pi, int x, int y) const; + /// + void write(WriteStream & os) const; + /// write normalized content + void normalize(NormalStream & ns) const; + /// + mode_type currentMode() const { return TEXT_MODE; } + /// + void infoize(odocstream & os) const; +private: + Inset * clone() const { return new InsetMathMakebox(*this); } + /// width of '[' in current font + mutable int w_; +}; + + + +/// AMS-style frame +class InsetMathBoxed : public InsetMathNest { +public: + /// + InsetMathBoxed(); + /// + void validate(LaTeXFeatures & features) const; + /// + void metrics(MetricsInfo & mi, Dimension & dim) const; + /// + void draw(PainterInfo & pi, int x, int y) const; + /// + void write(WriteStream & os) const; + /// write normalized content + void normalize(NormalStream & ns) const; + /// + void infoize(odocstream & os) const; +private: + Inset * clone() const { return new InsetMathBoxed(*this); } +}; + } // namespace lyx -#endif +#endif // MATH_MBOX diff --git a/src/mathed/InsetMathBoxed.cpp b/src/mathed/InsetMathBoxed.cpp deleted file mode 100644 index ea4aabc717..0000000000 --- a/src/mathed/InsetMathBoxed.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/** - * \file InsetMathBoxed.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 "InsetMathBoxed.h" - -#include "LaTeXFeatures.h" -#include "MathData.h" -#include "MathStream.h" -#include "MetricsInfo.h" - -#include "frontends/Painter.h" - -#include - - -namespace lyx { - -InsetMathBoxed::InsetMathBoxed() - : InsetMathNest(1) -{} - - -Inset * InsetMathBoxed::clone() const -{ - return new InsetMathBoxed(*this); -} - - -void InsetMathBoxed::metrics(MetricsInfo & mi, Dimension & dim) const -{ - cell(0).metrics(mi, dim); - metricsMarkers2(dim, 3); // 1 pixel space, 1 frame, 1 space - // Cache the inset dimension. - setDimCache(mi, dim); -} - - -void InsetMathBoxed::draw(PainterInfo & pi, int x, int y) const -{ - Dimension const dim = dimension(*pi.base.bv); - pi.pain.rectangle(x + 1, y - dim.ascent() + 1, - dim.width() - 2, dim.height() - 2, Color_foreground); - cell(0).draw(pi, x + 3, y); - setPosCache(pi, x, y); -} - - -void InsetMathBoxed::write(WriteStream & os) const -{ - os << "\\boxed{" << cell(0) << '}'; -} - - -void InsetMathBoxed::normalize(NormalStream & os) const -{ - os << "[boxed " << cell(0) << ']'; -} - - -void InsetMathBoxed::infoize(odocstream & os) const -{ - os << "Boxed: "; -} - - -void InsetMathBoxed::validate(LaTeXFeatures & features) const -{ - features.require("amsmath"); -} - - -} // namespace lyx diff --git a/src/mathed/InsetMathBoxed.h b/src/mathed/InsetMathBoxed.h deleted file mode 100644 index 895a1a7e53..0000000000 --- a/src/mathed/InsetMathBoxed.h +++ /dev/null @@ -1,45 +0,0 @@ -// -*- C++ -*- -/** - * \file InsetMathBoxed.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_BOXEDINSET_H -#define MATH_BOXEDINSET_H - -#include "InsetMathNest.h" - - -namespace lyx { - - -/// Non-AMS-style frame -class InsetMathBoxed : public InsetMathNest { -public: - /// - InsetMathBoxed(); - /// - void validate(LaTeXFeatures & features) const; - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - void write(WriteStream & os) const; - /// write normalized content - void normalize(NormalStream & ns) const; - /// - void infoize(odocstream & os) const; -private: - virtual Inset * clone() const; -}; - - -} // namespace lyx - -#endif diff --git a/src/mathed/InsetMathFBox.cpp b/src/mathed/InsetMathFBox.cpp deleted file mode 100644 index 2164ea7433..0000000000 --- a/src/mathed/InsetMathFBox.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/** - * \file InsetMathFBox.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 "InsetMathFBox.h" - -#include "MathData.h" -#include "MathStream.h" -#include "MetricsInfo.h" - -#include "frontends/Painter.h" - -#include - - -namespace lyx { - -InsetMathFBox::InsetMathFBox() - : InsetMathNest(1) -{} - - -Inset * InsetMathFBox::clone() const -{ - return new InsetMathFBox(*this); -} - - -InsetMath::mode_type InsetMathFBox::currentMode() const -{ - return TEXT_MODE; -} - - -void InsetMathFBox::metrics(MetricsInfo & mi, Dimension & dim) const -{ - FontSetChanger dummy(mi.base, "textnormal"); - cell(0).metrics(mi, dim); - metricsMarkers(dim, 3); // 1 pixel space, 1 frame, 1 space - // Cache the inset dimension. - setDimCache(mi, dim); -} - - -void InsetMathFBox::draw(PainterInfo & pi, int x, int y) const -{ - Dimension const dim = dimension(*pi.base.bv); - pi.pain.rectangle(x + 1, y - dim.ascent() + 1, - dim.width() - 2, dim.height() - 2, Color_foreground); - FontSetChanger dummy(pi.base, "textnormal"); - cell(0).draw(pi, x + 3, y); - setPosCache(pi, x, y); -} - - -void InsetMathFBox::write(WriteStream & os) const -{ - os << "\\fbox{" << cell(0) << '}'; -} - - -void InsetMathFBox::normalize(NormalStream & os) const -{ - os << "[fbox " << cell(0) << ']'; -} - - -void InsetMathFBox::infoize(odocstream & os) const -{ - os << "FBox: "; -} - - -} // namespace lyx diff --git a/src/mathed/InsetMathFBox.h b/src/mathed/InsetMathFBox.h deleted file mode 100644 index be141058bd..0000000000 --- a/src/mathed/InsetMathFBox.h +++ /dev/null @@ -1,45 +0,0 @@ -// -*- C++ -*- -/** - * \file InsetMathFBox.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_FBOXINSET_H -#define MATH_FBOXINSET_H - -#include "InsetMathNest.h" - - -namespace lyx { - - -/// Non-AMS-style frame -class InsetMathFBox : public InsetMathNest { -public: - /// - InsetMathFBox(); - /// - mode_type currentMode() const; - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - void write(WriteStream & os) const; - /// write normalized content - void normalize(NormalStream & ns) const; - /// - void infoize(odocstream & os) const; -private: - virtual Inset * clone() const; -}; - - - -} // namespace lyx -#endif diff --git a/src/mathed/InsetMathFrameBox.cpp b/src/mathed/InsetMathFrameBox.cpp deleted file mode 100644 index 4646f5e9e1..0000000000 --- a/src/mathed/InsetMathFrameBox.cpp +++ /dev/null @@ -1,94 +0,0 @@ -/** - * \file InsetMathFrameBox.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 "InsetMathFrameBox.h" - -#include "MathData.h" -#include "MathStream.h" -#include "MathSupport.h" -#include "MetricsInfo.h" - -#include "frontends/Painter.h" - - -namespace lyx { - -InsetMathFrameBox::InsetMathFrameBox() - : InsetMathNest(3) -{} - - -Inset * InsetMathFrameBox::clone() const -{ - return new InsetMathFrameBox(*this); -} - - -void InsetMathFrameBox::metrics(MetricsInfo & mi, Dimension & dim) const -{ - FontSetChanger dummy(mi.base, "textnormal"); - w_ = mathed_char_width(mi.base.font, '['); - InsetMathNest::metrics(mi); - dim = cell(0).dimension(*mi.base.bv); - dim += cell(1).dimension(*mi.base.bv); - dim += cell(2).dimension(*mi.base.bv); - metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); -} - - -void InsetMathFrameBox::draw(PainterInfo & pi, int x, int y) const -{ - FontSetChanger dummy(pi.base, "textnormal"); - Dimension const dim = dimension(*pi.base.bv); - pi.pain.rectangle(x + 1, y - dim.ascent() + 1, - dim.width() - 2, dim.height() - 2, Color_foreground); - x += 5; - BufferView const & bv = *pi.base.bv; - - drawStrBlack(pi, x, y, from_ascii("[")); - x += w_; - cell(0).draw(pi, x, y); - x += cell(0).dimension(bv).wid; - drawStrBlack(pi, x, y, from_ascii("]")); - x += w_ + 4; - - drawStrBlack(pi, x, y, from_ascii("[")); - x += w_; - cell(1).draw(pi, x, y); - x += cell(1).dimension(bv).wid; - drawStrBlack(pi, x, y, from_ascii("]")); - x += w_ + 4; - - cell(2).draw(pi, x, y); - drawMarkers(pi, x, y); -} - - -void InsetMathFrameBox::write(WriteStream & os) const -{ - os << "\\framebox"; - os << '[' << cell(0) << ']'; - if (cell(1).size()) - os << '[' << cell(1) << ']'; - os << '{' << cell(2) << '}'; -} - - -void InsetMathFrameBox::normalize(NormalStream & os) const -{ - os << "[framebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']'; -} - - -} // namespace lyx diff --git a/src/mathed/InsetMathFrameBox.h b/src/mathed/InsetMathFrameBox.h deleted file mode 100644 index e6701177e9..0000000000 --- a/src/mathed/InsetMathFrameBox.h +++ /dev/null @@ -1,45 +0,0 @@ -// -*- C++ -*- -/** - * \file InsetMathFrameBox.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_FRAMEBOXINSET_H -#define MATH_FRAMEBOXINSET_H - -#include "InsetMathNest.h" - - -namespace lyx { - - -/// Extra nesting -class InsetMathFrameBox : public InsetMathNest { -public: - /// - InsetMathFrameBox(); - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - void write(WriteStream & os) const; - /// write normalized content - void normalize(NormalStream & ns) const; - /// - mode_type currentMode() const { return TEXT_MODE; } -private: - virtual Inset * clone() const; - /// width of '[' in current font - mutable int w_; -}; - - - -} // namespace lyx -#endif diff --git a/src/mathed/InsetMathMakebox.cpp b/src/mathed/InsetMathMakebox.cpp deleted file mode 100644 index c8ba21931e..0000000000 --- a/src/mathed/InsetMathMakebox.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/** - * \file InsetMathMakebox.cpp - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Ling Li - * - * Full author contact details are available in file CREDITS. - */ - -#include - -#include "InsetMathMakebox.h" -#include "MathData.h" -#include "MathStream.h" -#include "MathSupport.h" - -#include "support/std_ostream.h" - - -namespace lyx { - -InsetMathMakebox::InsetMathMakebox() - : InsetMathNest(3) -{} - - -Inset * InsetMathMakebox::clone() const -{ - return new InsetMathMakebox(*this); -} - - -void InsetMathMakebox::metrics(MetricsInfo & mi, Dimension & dim) const -{ - FontSetChanger dummy(mi.base, from_ascii("textnormal")); - w_ = mathed_char_width(mi.base.font, '['); - InsetMathNest::metrics(mi); - dim = cell(0).dimension(*mi.base.bv); - dim += cell(1).dimension(*mi.base.bv); - dim += cell(2).dimension(*mi.base.bv); - dim.wid += 4 * w_ + 4; - metricsMarkers(dim); - // Cache the inset dimension. - setDimCache(mi, dim); -} - - -void InsetMathMakebox::draw(PainterInfo & pi, int x, int y) const -{ - FontSetChanger dummy(pi.base, from_ascii("textnormal")); - drawMarkers(pi, x, y); - - drawStrBlack(pi, x, y, from_ascii("[")); - x += w_; - cell(0).draw(pi, x, y); - x += cell(0).dimension(*pi.base.bv).width(); - drawStrBlack(pi, x, y, from_ascii("]")); - x += w_ + 2; - - drawStrBlack(pi, x, y, from_ascii("[")); - x += w_; - cell(1).draw(pi, x, y); - x += cell(1).dimension(*pi.base.bv).wid; - drawStrBlack(pi, x, y, from_ascii("]")); - x += w_ + 2; - - cell(2).draw(pi, x, y); - setPosCache(pi, x, y); -} - - -void InsetMathMakebox::write(WriteStream & os) const -{ - os << "\\makebox"; - os << '[' << cell(0) << ']'; - if (cell(1).size()) - os << '[' << cell(1) << ']'; - os << '{' << cell(2) << '}'; -} - - -void InsetMathMakebox::normalize(NormalStream & os) const -{ - os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']'; -} - - -void InsetMathMakebox::infoize(odocstream & os) const -{ - os << "Makebox (width: " << cell(0) - << " pos: " << cell(1) << ")"; -} - - -} // namespace lyx diff --git a/src/mathed/InsetMathMakebox.h b/src/mathed/InsetMathMakebox.h deleted file mode 100644 index 56480ee310..0000000000 --- a/src/mathed/InsetMathMakebox.h +++ /dev/null @@ -1,48 +0,0 @@ -// -*- C++ -*- -/** - * \file InsetMathMakebox.h - * This file is part of LyX, the document processor. - * Licence details can be found in the file COPYING. - * - * \author Ling Li - * - * Full author contact details are available in file CREDITS. - */ - -#ifndef MATH_MAKEBOXINSET_H -#define MATH_MAKEBOXINSET_H - -#include "InsetMathNest.h" - - -namespace lyx { - -/// Extra nesting: \\makebox. -// consolidate with InsetMathFrameBox? - -class InsetMathMakebox : public InsetMathNest { -public: - /// - InsetMathMakebox(); - /// - void metrics(MetricsInfo & mi, Dimension & dim) const; - /// - void draw(PainterInfo & pi, int x, int y) const; - /// - void write(WriteStream & os) const; - /// write normalized content - void normalize(NormalStream & ns) const; - /// - mode_type currentMode() const { return TEXT_MODE; } - /// - void infoize(odocstream & os) const; -private: - virtual Inset * clone() const; - /// width of '[' in current font - mutable int w_; -}; - - - -} // namespace lyx -#endif