2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_fontinset.C
|
|
|
|
|
* 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>
|
|
|
|
|
|
|
|
|
|
#include "math_fontinset.h"
|
2003-09-07 21:25:37 +00:00
|
|
|
|
#include "math_data.h"
|
2002-05-30 07:09:54 +00:00
|
|
|
|
#include "math_mathmlstream.h"
|
2002-07-17 10:25:33 +00:00
|
|
|
|
#include "math_parser.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
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
|
|
|
|
|
2002-07-17 10:25:33 +00:00
|
|
|
|
MathFontInset::MathFontInset(latexkeys const * key)
|
|
|
|
|
: MathNestInset(1), key_(key)
|
2002-08-01 15:53:46 +00:00
|
|
|
|
{}
|
2002-05-30 07:09:54 +00:00
|
|
|
|
|
|
|
|
|
|
2003-07-25 17:11:25 +00:00
|
|
|
|
auto_ptr<InsetBase> MathFontInset::clone() const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2003-07-25 17:11:25 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new MathFontInset(*this));
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-07-18 11:02:33 +00:00
|
|
|
|
MathInset::mode_type MathFontInset::currentMode() const
|
|
|
|
|
{
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-02 10:03:27 +00:00
|
|
|
|
void MathFontInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
2002-05-30 07:09:54 +00:00
|
|
|
|
{
|
2003-03-21 14:20:48 +00:00
|
|
|
|
FontSetChanger dummy(mi.base, key_->name.c_str());
|
2003-05-28 13:22:36 +00:00
|
|
|
|
cell(0).metrics(mi, dim_);
|
|
|
|
|
metricsMarkers(1);
|
2003-06-02 10:03:27 +00:00
|
|
|
|
dim = dim_;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void MathFontInset::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);
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2003-06-30 23:56:22 +00:00
|
|
|
|
void MathFontInset::metricsT(TextMetricsInfo const & mi, Dimension & /*dim*/) 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathFontInset::drawT(TextPainter & pain, int x, int y) const
|
|
|
|
|
{
|
2002-08-02 14:29:42 +00:00
|
|
|
|
cell(0).drawT(pain, x, y);
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-08-01 15:53:46 +00:00
|
|
|
|
string MathFontInset::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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathFontInset::validate(LaTeXFeatures & features) const
|
|
|
|
|
{
|
2002-09-19 13:39:43 +00:00
|
|
|
|
MathNestInset::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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MathFontInset::infoize(std::ostream & os) const
|
|
|
|
|
{
|
2002-07-17 10:25:33 +00:00
|
|
|
|
os << "Font: " << key_->name;
|
2002-05-30 07:09:54 +00:00
|
|
|
|
}
|