mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-06 00:10:59 +00:00
support for color in math
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@7851 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
d839975cfc
commit
45d3b8c89c
@ -35,6 +35,8 @@ libmathed_la_SOURCES = \
|
||||
math_casesinset.h \
|
||||
math_charinset.C \
|
||||
math_charinset.h \
|
||||
math_colorinset.C \
|
||||
math_colorinset.h \
|
||||
math_commentinset.C \
|
||||
math_commentinset.h \
|
||||
math_cursor.C \
|
||||
|
@ -305,7 +305,7 @@ dispatch_result InsetFormulaBase::localDispatch(FuncRequest const & cmd)
|
||||
{
|
||||
lyxerr << "InsetFormulaBase::localDispatch: act: " << cmd.action
|
||||
<< " arg: '" << cmd.argument
|
||||
<< " x: '" << cmd.x
|
||||
<< "' x: '" << cmd.x
|
||||
<< " y: '" << cmd.y
|
||||
<< "' button: " << cmd.button() << endl;
|
||||
|
||||
|
@ -64,8 +64,8 @@ void MathCharInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
} else if ((char_ == '>' || char_ == '<') && has_math_fonts) {
|
||||
FontSetChanger dummy(mi.base, "cmm");
|
||||
mathed_char_dim(mi.base.font, char_, dim);
|
||||
} else if (slanted(char_) && mi.base.fontname == "mathnormal") {
|
||||
ShapeChanger dummy(mi.base.font, LyXFont::ITALIC_SHAPE);
|
||||
} else if (!slanted(char_) && mi.base.fontname == "mathnormal") {
|
||||
ShapeChanger dummy(mi.base.font, LyXFont::UP_SHAPE);
|
||||
mathed_char_dim(mi.base.font, char_, dim);
|
||||
} else {
|
||||
mathed_char_dim(mi.base.font, char_, dim);
|
||||
@ -100,8 +100,8 @@ void MathCharInset::draw(PainterInfo & pi, int x, int y) const
|
||||
} else if ((char_ == '>' || char_ == '<') && has_math_fonts) {
|
||||
FontSetChanger dummy(pi.base, "cmm");
|
||||
pi.draw(x, y, char_);
|
||||
} else if (slanted(char_) && pi.base.fontname == "mathnormal") {
|
||||
ShapeChanger dummy(pi.base.font, LyXFont::ITALIC_SHAPE);
|
||||
} else if (!slanted(char_) && pi.base.fontname == "mathnormal") {
|
||||
ShapeChanger dummy(pi.base.font, LyXFont::UP_SHAPE);
|
||||
pi.draw(x, y, char_);
|
||||
} else {
|
||||
pi.draw(x, y, char_);
|
||||
|
88
src/mathed/math_colorinset.C
Normal file
88
src/mathed/math_colorinset.C
Normal file
@ -0,0 +1,88 @@
|
||||
/**
|
||||
* \file math_colorinset.C
|
||||
* 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 "math_colorinset.h"
|
||||
#include "math_data.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "math_support.h"
|
||||
|
||||
#include "LaTeXFeatures.h"
|
||||
|
||||
#include "support/std_ostream.h"
|
||||
|
||||
using std::auto_ptr;
|
||||
|
||||
|
||||
MathColorInset::MathColorInset()
|
||||
: MathNestInset(2)
|
||||
{}
|
||||
|
||||
|
||||
auto_ptr<InsetBase> MathColorInset::clone() const
|
||||
{
|
||||
return auto_ptr<InsetBase>(new MathColorInset(*this));
|
||||
}
|
||||
|
||||
|
||||
void MathColorInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
FontSetChanger dummy(mi.base, "textnormal");
|
||||
w_ = mathed_char_width(mi.base.font, '[');
|
||||
MathNestInset::metrics(mi);
|
||||
dim_ = cell(0).dim();
|
||||
dim_ += cell(1).dim();
|
||||
dim_.wid += 2 * w_ + 4;
|
||||
metricsMarkers();
|
||||
dim = dim_;
|
||||
}
|
||||
|
||||
|
||||
void MathColorInset::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
FontSetChanger dummy(pi.base, "textnormal");
|
||||
drawMarkers(pi, x, y);
|
||||
|
||||
drawStrBlack(pi, x, y, "[");
|
||||
x += w_;
|
||||
cell(0).draw(pi, x, y);
|
||||
x += cell(0).width();
|
||||
drawStrBlack(pi, x, y, "]");
|
||||
x += w_ + 2;
|
||||
|
||||
ColorChanger dummy1(pi.base.font, asString(cell(0)));
|
||||
cell(1).draw(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
void MathColorInset::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
MathNestInset::validate(features);
|
||||
features.require("color");
|
||||
}
|
||||
|
||||
|
||||
void MathColorInset::write(WriteStream & os) const
|
||||
{
|
||||
os << "\\color" << '{' << cell(0) << '}' << '{' << cell(1) << '}';
|
||||
}
|
||||
|
||||
|
||||
void MathColorInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[color " << cell(0) << ' ' << cell(1) << ']';
|
||||
}
|
||||
|
||||
|
||||
void MathColorInset::infoize(std::ostream & os) const
|
||||
{
|
||||
os << "Color: " << cell(0);
|
||||
}
|
42
src/mathed/math_colorinset.h
Normal file
42
src/mathed/math_colorinset.h
Normal file
@ -0,0 +1,42 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file math_colorinset.h
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef MATH_COLORINSET_H
|
||||
#define MATH_COLORINSET_H
|
||||
|
||||
#include "math_nestinset.h"
|
||||
|
||||
/// Change colours.
|
||||
|
||||
class MathColorInset : public MathNestInset {
|
||||
public:
|
||||
///
|
||||
MathColorInset();
|
||||
///
|
||||
virtual std::auto_ptr<InsetBase> clone() const;
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
/// we need package color
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
/// write normalized content
|
||||
void normalize(NormalStream & ns) const;
|
||||
///
|
||||
void infoize(std::ostream & os) const;
|
||||
private:
|
||||
/// width of '[' in current font
|
||||
mutable int w_;
|
||||
};
|
||||
|
||||
#endif
|
@ -18,6 +18,7 @@
|
||||
#include "math_boxinset.h"
|
||||
#include "math_boldsymbolinset.h"
|
||||
#include "math_casesinset.h"
|
||||
#include "math_colorinset.h"
|
||||
#include "math_decorationinset.h"
|
||||
#include "math_dotsinset.h"
|
||||
#include "math_ertinset.h"
|
||||
@ -309,6 +310,8 @@ MathAtom createMathInset(string const & s)
|
||||
return MathAtom(new MathErtInset);
|
||||
if (s == "boldsymbol")
|
||||
return MathAtom(new MathBoldsymbolInset);
|
||||
if (s == "color")
|
||||
return MathAtom(new MathColorInset);
|
||||
|
||||
if (MathMacroTable::has(s))
|
||||
return MathAtom(new MathMacro(s));
|
||||
|
@ -175,6 +175,7 @@ char const * MathHullInset::standardFont() const
|
||||
{
|
||||
if (type_ == "none")
|
||||
return "lyxnochange";
|
||||
lyxerr << "standard font: mathnormal\n";
|
||||
return "mathnormal";
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,8 @@
|
||||
#include "math_mathmlstream.h"
|
||||
#include "math_support.h"
|
||||
|
||||
#include "support/std_ostream.h"
|
||||
|
||||
using std::auto_ptr;
|
||||
|
||||
|
||||
@ -80,3 +82,10 @@ void MathMakeboxInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
|
||||
}
|
||||
|
||||
|
||||
void MathMakeboxInset::infoize(std::ostream & os) const
|
||||
{
|
||||
os << "Makebox (width: " << cell(0)
|
||||
<< " pos: " << cell(1) << ")";
|
||||
}
|
||||
|
@ -33,6 +33,8 @@ public:
|
||||
void normalize(NormalStream & ns) const;
|
||||
///
|
||||
mode_type currentMode() const { return TEXT_MODE; }
|
||||
///
|
||||
void infoize(std::ostream & os) const;
|
||||
private:
|
||||
/// width of '[' in current font
|
||||
mutable int w_;
|
||||
|
@ -534,7 +534,7 @@ LyXFont::FONT_SHAPE const inh_shape = LyXFont::INHERIT_SHAPE;
|
||||
fontinfo fontinfos[] = {
|
||||
// math fonts
|
||||
{"mathnormal", inh_family, LyXFont::MEDIUM_SERIES,
|
||||
LyXFont::UP_SHAPE, LColor::math},
|
||||
LyXFont::ITALIC_SHAPE, LColor::math},
|
||||
{"mathbf", inh_family, LyXFont::BOLD_SERIES,
|
||||
inh_shape, LColor::math},
|
||||
{"mathcal", LyXFont::CMSY_FAMILY, inh_series,
|
||||
|
Loading…
Reference in New Issue
Block a user