2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
|
* \file InsetMathFont.cpp
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
|
#include <config.h>
|
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathFont.h"
|
2007-04-26 16:05:57 +00:00
|
|
|
|
#include "MathData.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
|
#include "MathStream.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "MathParser.h"
|
2002-05-30 07:09:54 +00:00
|
|
|
|
#include "LaTeXFeatures.h"
|
2003-09-05 17:23:11 +00:00
|
|
|
|
#include "support/std_ostream.h"
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathFont::InsetMathFont(latexkeys const * key)
|
|
|
|
|
: InsetMathNest(1), key_(key)
|
2002-08-01 15:53:46 +00:00
|
|
|
|
{}
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
|
|
|
|
|
2007-04-29 13:39:47 +00:00
|
|
|
|
auto_ptr<Inset> InsetMathFont::doClone() const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2007-04-29 13:39:47 +00:00
|
|
|
|
return auto_ptr<Inset>(new InsetMathFont(*this));
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMath::mode_type InsetMathFont::currentMode() const
|
2002-07-18 11:02:33 +00:00
|
|
|
|
{
|
2002-08-01 11:48:53 +00:00
|
|
|
|
if (key_->extra == "mathmode")
|
|
|
|
|
return MATH_MODE;
|
|
|
|
|
if (key_->extra == "textmode")
|
|
|
|
|
return TEXT_MODE;
|
|
|
|
|
return UNDECIDED_MODE;
|
2002-07-18 11:02:33 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool InsetMathFont::metrics(MetricsInfo & mi, Dimension & dim) const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
FontSetChanger dummy(mi.base, key_->name);
|
2004-01-30 11:41:12 +00:00
|
|
|
|
cell(0).metrics(mi, dim);
|
|
|
|
|
metricsMarkers(dim);
|
2006-11-28 15:15:49 +00:00
|
|
|
|
if (dim_ == dim)
|
|
|
|
|
return false;
|
2004-01-30 11:41:12 +00:00
|
|
|
|
dim_ = dim;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
return true;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathFont::draw(PainterInfo & pi, int x, int y) const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2003-03-21 14:20:48 +00:00
|
|
|
|
FontSetChanger dummy(pi.base, key_->name.c_str());
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).draw(pi, x + 1, y);
|
2002-06-24 15:37:14 +00:00
|
|
|
|
drawMarkers(pi, x, y);
|
2005-04-03 07:48:20 +00:00
|
|
|
|
setPosCache(pi, x, y);
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathFont::metricsT(TextMetricsInfo const & mi, Dimension &) const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2003-05-28 13:22:36 +00:00
|
|
|
|
cell(0).metricsT(mi, dim_);
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathFont::drawT(TextPainter & pain, int x, int y) const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).drawT(pain, x, y);
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
docstring InsetMathFont::name() const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2002-08-01 15:53:46 +00:00
|
|
|
|
return key_->name;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathFont::validate(LaTeXFeatures & features) const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathNest::validate(features);
|
2002-05-30 07:09:54 +00:00
|
|
|
|
// Make sure amssymb is put in preamble if Blackboard Bold or
|
|
|
|
|
// Fraktur used:
|
2002-07-17 10:25:33 +00:00
|
|
|
|
if (key_->name == "mathfrak" || key_->name == "mathbb")
|
2002-05-30 07:09:54 +00:00
|
|
|
|
features.require("amssymb");
|
2005-06-24 08:25:33 +00:00
|
|
|
|
if (key_->name == "text")
|
|
|
|
|
features.require("amsmath");
|
2006-04-14 14:30:43 +00:00
|
|
|
|
if (key_->name == "textipa")
|
|
|
|
|
features.require("tipa");
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void InsetMathFont::infoize(odocstream & os) const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2002-07-17 10:25:33 +00:00
|
|
|
|
os << "Font: " << key_->name;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|