2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2007-04-25 03:01:35 +00:00
|
|
|
|
* \file InsetMathKern.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.
|
|
|
|
|
*/
|
2001-12-05 08:04:20 +00:00
|
|
|
|
|
2003-08-19 13:00:56 +00:00
|
|
|
|
#include <config.h>
|
2001-08-21 14:20:50 +00:00
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathKern.h"
|
2006-10-22 10:15:23 +00:00
|
|
|
|
#include "MathStream.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "MathStream.h"
|
|
|
|
|
#include "MathSupport.h"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "Dimension.h"
|
2001-08-21 14:20:50 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
using std::string;
|
2003-07-25 17:11:25 +00:00
|
|
|
|
using std::auto_ptr;
|
|
|
|
|
|
2002-01-11 17:57:02 +00:00
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathKern::InsetMathKern()
|
2007-04-22 08:26:06 +00:00
|
|
|
|
{
|
|
|
|
|
dim_.asc = 0;
|
|
|
|
|
dim_.des = 0;
|
|
|
|
|
}
|
2002-03-27 10:51:46 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathKern::InsetMathKern(LyXLength const & w)
|
2002-03-27 10:51:46 +00:00
|
|
|
|
: wid_(w)
|
2007-04-22 08:26:06 +00:00
|
|
|
|
{
|
|
|
|
|
dim_.asc = 0;
|
|
|
|
|
dim_.des = 0;
|
|
|
|
|
}
|
2002-03-27 10:51:46 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-22 10:15:23 +00:00
|
|
|
|
InsetMathKern::InsetMathKern(docstring const & s)
|
|
|
|
|
: wid_(to_utf8(s))
|
2007-04-22 08:26:06 +00:00
|
|
|
|
{
|
|
|
|
|
dim_.asc = 0;
|
|
|
|
|
dim_.des = 0;
|
|
|
|
|
}
|
2001-08-21 14:20:50 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
auto_ptr<InsetBase> InsetMathKern::doClone() const
|
2001-08-21 14:20:50 +00:00
|
|
|
|
{
|
2006-09-16 18:11:38 +00:00
|
|
|
|
return auto_ptr<InsetBase>(new InsetMathKern(*this));
|
2001-08-21 14:20:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool InsetMathKern::metrics(MetricsInfo & mi, Dimension & dim) const
|
2001-08-21 14:20:50 +00:00
|
|
|
|
{
|
2007-04-22 08:26:06 +00:00
|
|
|
|
int wid_pixel = wid_.inPixels(0, mathed_char_width(mi.base.font, 'M'));
|
|
|
|
|
if (wid_pixel == dim_.wid)
|
2006-11-28 15:15:49 +00:00
|
|
|
|
return false;
|
2007-04-22 08:26:06 +00:00
|
|
|
|
dim_.wid = wid_pixel;
|
|
|
|
|
dim = dim_;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
return true;
|
2001-08-21 14:20:50 +00:00
|
|
|
|
}
|
2001-11-08 12:06:56 +00:00
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathKern::draw(PainterInfo &, int, int) const
|
2002-03-25 12:11:25 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathKern::write(WriteStream & os) const
|
2001-11-08 12:06:56 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
os << "\\kern" << from_utf8(wid_.asLatexString()) << ' ';
|
2001-11-08 12:06:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
void InsetMathKern::normalize(NormalStream & os) const
|
2001-11-08 12:06:56 +00:00
|
|
|
|
{
|
2006-10-22 10:15:23 +00:00
|
|
|
|
os << "[kern " << from_utf8(wid_.asLatexString()) << ']';
|
2001-11-08 12:06:56 +00:00
|
|
|
|
}
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|