mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
0a90c42b86
6047: Lyx 1.6.3 unable to typeset the third chemical equation of the file mhchem.lyx (package mhchem) 4043: mhchem support 5394: support for the mhchems's \ce command The \ce and \cf insets are text mode environments that allow entering spaces and mathmode commands. LyX leaves them alone and doesn't try to be smart, i.e., the behaviour is exactly the same we had in the old days with text-in-math mode environments, before the introduction of the \ensuremath and \lyxmathsym macros. This means that in those environments one has to know what he is doing, as LyX will not offer any protection. The hack of enclosing \ce and \cf in a \text{} environment in order to be able to enter spaces is no longer necessary. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@30338 a592a061-630c-0410-9148-cb99ea01b6c8
116 lines
2.2 KiB
C++
116 lines
2.2 KiB
C++
/**
|
|
* \file InsetMathFont.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 "InsetMathFont.h"
|
|
|
|
#include "LaTeXFeatures.h"
|
|
#include "MathData.h"
|
|
#include "MathStream.h"
|
|
#include "MathParser.h"
|
|
#include "MetricsInfo.h"
|
|
|
|
#include <ostream>
|
|
|
|
|
|
namespace lyx {
|
|
|
|
InsetMathFont::InsetMathFont(latexkeys const * key)
|
|
: InsetMathNest(1), key_(key)
|
|
{}
|
|
|
|
|
|
Inset * InsetMathFont::clone() const
|
|
{
|
|
return new InsetMathFont(*this);
|
|
}
|
|
|
|
|
|
InsetMath::mode_type InsetMathFont::currentMode() const
|
|
{
|
|
if (key_->extra == "mathmode")
|
|
return MATH_MODE;
|
|
if (key_->extra == "textmode")
|
|
return TEXT_MODE;
|
|
return UNDECIDED_MODE;
|
|
}
|
|
|
|
|
|
bool InsetMathFont::lockedMode() const
|
|
{
|
|
if (key_->extra == "forcetext")
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
|
|
void InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const
|
|
{
|
|
FontSetChanger dummy(mi.base, key_->name);
|
|
cell(0).metrics(mi, dim);
|
|
metricsMarkers(dim);
|
|
}
|
|
|
|
|
|
void InsetMathFont::draw(PainterInfo & pi, int x, int y) const
|
|
{
|
|
FontSetChanger dummy(pi.base, key_->name.c_str());
|
|
cell(0).draw(pi, x + 1, y);
|
|
drawMarkers(pi, x, y);
|
|
setPosCache(pi, x, y);
|
|
}
|
|
|
|
|
|
void InsetMathFont::metricsT(TextMetricsInfo const & mi, Dimension &) const
|
|
{
|
|
// FIXME: BROKEN!
|
|
Dimension dim;
|
|
cell(0).metricsT(mi, dim);
|
|
}
|
|
|
|
|
|
void InsetMathFont::drawT(TextPainter & pain, int x, int y) const
|
|
{
|
|
cell(0).drawT(pain, x, y);
|
|
}
|
|
|
|
|
|
docstring InsetMathFont::name() const
|
|
{
|
|
return key_->name;
|
|
}
|
|
|
|
|
|
void InsetMathFont::validate(LaTeXFeatures & features) const
|
|
{
|
|
InsetMathNest::validate(features);
|
|
// Make sure amssymb is put in preamble if Blackboard Bold or
|
|
// Fraktur used:
|
|
if (key_->name == "mathfrak" || key_->name == "mathbb")
|
|
features.require("amssymb");
|
|
if (key_->name == "text" || key_->name == "textnormal"
|
|
|| (key_->name.length() == 6 && key_->name.substr(0, 4) == "text"))
|
|
features.require("amstext");
|
|
if (key_->name == "textipa")
|
|
features.require("tipa");
|
|
if (key_->name == "ce" || key_->name == "cf")
|
|
features.require("mhchem");
|
|
}
|
|
|
|
|
|
void InsetMathFont::infoize(odocstream & os) const
|
|
{
|
|
os << "Font: " << key_->name;
|
|
}
|
|
|
|
|
|
} // namespace lyx
|