* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
- * \author André Pönitz
+ * \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "InsetMathFontOld.h"
+
#include "MathData.h"
-#include "MathStream.h"
#include "MathParser.h"
#include "MathStream.h"
-#include "support/std_ostream.h"
+#include "MathSupport.h"
+#include "MetricsInfo.h"
+#include "support/gettext.h"
+#include "support/lstrings.h"
-namespace lyx {
+#include <ostream>
-using std::auto_ptr;
+using namespace lyx::support;
+namespace lyx {
-InsetMathFontOld::InsetMathFontOld(latexkeys const * key)
- : InsetMathNest(1), key_(key)
+InsetMathFontOld::InsetMathFontOld(Buffer * buf, latexkeys const * key)
+ : InsetMathNest(buf, 1), key_(key), current_mode_(TEXT_MODE)
{
//lock(true);
}
-auto_ptr<InsetBase> InsetMathFontOld::doClone() const
+Inset * InsetMathFontOld::clone() const
{
- return auto_ptr<InsetBase>(new InsetMathFontOld(*this));
+ return new InsetMathFontOld(*this);
}
-bool InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const
+void InsetMathFontOld::metrics(MetricsInfo & mi, Dimension & dim) const
{
- FontSetChanger dummy(mi.base, key_->name.c_str());
+ current_mode_ = isTextFont(from_ascii(mi.base.fontname))
+ ? TEXT_MODE : MATH_MODE;
+
+ docstring const font = current_mode_ == MATH_MODE
+ ? "math" + key_->name : "text" + key_->name;
+
+ // When \cal is used in text mode, the font is not changed
+ bool really_change_font = font != "textcal";
+
+ FontSetChanger dummy(mi.base, font, really_change_font);
cell(0).metrics(mi, dim);
metricsMarkers(dim);
- if (dim_ == dim)
- return false;
- dim_ = dim;
- return true;
}
void InsetMathFontOld::draw(PainterInfo & pi, int x, int y) const
{
- FontSetChanger dummy(pi.base, key_->name.c_str());
+ current_mode_ = isTextFont(from_ascii(pi.base.fontname))
+ ? TEXT_MODE : MATH_MODE;
+
+ docstring const font = current_mode_ == MATH_MODE
+ ? "math" + key_->name : "text" + key_->name;
+
+ // When \cal is used in text mode, the font is not changed
+ bool really_change_font = font != "textcal";
+
+ FontSetChanger dummy(pi.base, font, really_change_font);
cell(0).draw(pi, x + 1, y);
drawMarkers(pi, x, y);
}
void InsetMathFontOld::infoize(odocstream & os) const
{
- os << "Font: " << key_->name;
+ os << bformat(_("Font: %1$s"), key_->name);
}