mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Ling Li's makebox support
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6943 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
9101fa688c
commit
8bfa794d28
@ -1,3 +1,13 @@
|
||||
2003-05-06 Ling Li <ling@caltech.edu>
|
||||
|
||||
* Makefile, math_makeboxinset.[Ch]:
|
||||
* math_factory.C (createMathInset):
|
||||
* math_parser.C (parse1): New support for \makebox.
|
||||
|
||||
* math_nestinset.C (drawMarkers, drawMarkers2):
|
||||
* math_boxinset.C, math_frameboxinset.C (draw):
|
||||
Fix spacing and marker length.
|
||||
|
||||
2003-05-03 John Levon <levon@movementarian.org>
|
||||
|
||||
* formula.C:
|
||||
|
@ -100,6 +100,8 @@ libmathed_la_SOURCES = \
|
||||
math_macrotemplate.h \
|
||||
math_macrotable.C \
|
||||
math_macrotable.h \
|
||||
math_makeboxinset.C \
|
||||
math_makeboxinset.h \
|
||||
math_mathmlstream.C \
|
||||
math_mathmlstream.h \
|
||||
math_matrixinset.C \
|
||||
|
@ -46,7 +46,7 @@ void MathBoxInset::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
FontSetChanger dummy(pi.base, "textnormal");
|
||||
cell(0).draw(pi, x, y);
|
||||
drawMarkers2(pi, x + 1, y);
|
||||
drawMarkers2(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "math_macrotable.h"
|
||||
#include "math_macrotemplate.h"
|
||||
#include "math_macroarg.h"
|
||||
#include "math_makeboxinset.h"
|
||||
#include "math_parboxinset.h"
|
||||
#include "math_rootinset.h"
|
||||
#include "math_sizeinset.h"
|
||||
@ -259,6 +260,8 @@ MathAtom createMathInset(string const & s)
|
||||
return MathAtom(new MathMacroArgument(s[2] - '0'));
|
||||
if (s == "framebox")
|
||||
return MathAtom(new MathFrameboxInset);
|
||||
if (s == "makebox")
|
||||
return MathAtom(new MathMakeboxInset);
|
||||
if (s == "kern")
|
||||
return MathAtom(new MathKernInset);
|
||||
if (s == "xymatrix")
|
||||
|
75
src/mathed/math_makeboxinset.C
Normal file
75
src/mathed/math_makeboxinset.C
Normal file
@ -0,0 +1,75 @@
|
||||
#include <config.h>
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation
|
||||
#endif
|
||||
|
||||
#include "math_makeboxinset.h"
|
||||
#include "math_support.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "math_streamstr.h"
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
|
||||
|
||||
MathMakeboxInset::MathMakeboxInset()
|
||||
: MathNestInset(3)
|
||||
{}
|
||||
|
||||
|
||||
MathInset * MathMakeboxInset::clone() const
|
||||
{
|
||||
return new MathMakeboxInset(*this);
|
||||
}
|
||||
|
||||
|
||||
void MathMakeboxInset::metrics(MetricsInfo & mi) 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_ += cell(2).dim();
|
||||
dim_.w += 4 * w_ + 4;
|
||||
metricsMarkers2();
|
||||
}
|
||||
|
||||
|
||||
void MathMakeboxInset::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
FontSetChanger dummy(pi.base, "textnormal");
|
||||
drawMarkers2(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;
|
||||
|
||||
drawStrBlack(pi, x, y, "[");
|
||||
x += w_;
|
||||
cell(1).draw(pi, x, y);
|
||||
x += cell(1).width();
|
||||
drawStrBlack(pi, x, y, "]");
|
||||
x += w_ + 2;
|
||||
|
||||
cell(2).draw(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
void MathMakeboxInset::write(WriteStream & os) const
|
||||
{
|
||||
os << "\\makebox";
|
||||
os << '[' << cell(0) << ']';
|
||||
if (cell(1).size())
|
||||
os << '[' << cell(1) << ']';
|
||||
os << '{' << cell(2) << '}';
|
||||
}
|
||||
|
||||
|
||||
void MathMakeboxInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[makebox " << cell(0) << ' ' << cell(1) << ' ' << cell(2) << ']';
|
||||
}
|
40
src/mathed/math_makeboxinset.h
Normal file
40
src/mathed/math_makeboxinset.h
Normal file
@ -0,0 +1,40 @@
|
||||
// -*- C++ -*-
|
||||
#ifndef MATH_MAKEBOXINSET_H
|
||||
#define MATH_MAKEBOXINSET_H
|
||||
|
||||
#include "math_nestinset.h"
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
/** Extra nesting: \\makebox.
|
||||
* \author Ling Li
|
||||
*
|
||||
* Full author contact details are available in file CREDITS
|
||||
*/
|
||||
|
||||
// consolidate with MathFrameboxInset?
|
||||
|
||||
class MathMakeboxInset : public MathNestInset {
|
||||
public:
|
||||
///
|
||||
MathMakeboxInset();
|
||||
///
|
||||
MathInset * clone() const;
|
||||
///
|
||||
void metrics(MetricsInfo & mi) const;
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
/// write normalized content
|
||||
void normalize(NormalStream & ns) const;
|
||||
///
|
||||
mode_type currentMode() const { return TEXT_MODE; }
|
||||
private:
|
||||
/// width of '[' in current font
|
||||
mutable int w_;
|
||||
};
|
||||
|
||||
#endif
|
@ -201,7 +201,7 @@ void MathNestInset::drawMarkers(PainterInfo & pi, int x, int y) const
|
||||
pi.pain.line(x, d - 3, x, d, LColor::mathframe);
|
||||
pi.pain.line(t, d - 3, t, d, LColor::mathframe);
|
||||
pi.pain.line(x, d, x + 3, d, LColor::mathframe);
|
||||
pi.pain.line(t - 2, d, t, d, LColor::mathframe);
|
||||
pi.pain.line(t - 3, d, t, d, LColor::mathframe);
|
||||
}
|
||||
|
||||
|
||||
@ -215,7 +215,7 @@ void MathNestInset::drawMarkers2(PainterInfo & pi, int x, int y) const
|
||||
pi.pain.line(x, a + 3, x, a, LColor::mathframe);
|
||||
pi.pain.line(t, a + 3, t, a, LColor::mathframe);
|
||||
pi.pain.line(x, a, x + 3, a, LColor::mathframe);
|
||||
pi.pain.line(t - 2, a, t, a, LColor::mathframe);
|
||||
pi.pain.line(t - 3, a, t, a, LColor::mathframe);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1138,7 +1138,7 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
|
||||
parse2(cell->back(), FLAG_ITEM, mode, false);
|
||||
}
|
||||
|
||||
else if (t.cs() == "framebox") {
|
||||
else if (t.cs() == "framebox" || t.cs() == "makebox") {
|
||||
cell->push_back(createMathInset(t.cs()));
|
||||
parse(cell->back().nucleus()->cell(0), FLAG_OPTION, MathInset::TEXT_MODE);
|
||||
parse(cell->back().nucleus()->cell(1), FLAG_OPTION, MathInset::TEXT_MODE);
|
||||
|
Loading…
Reference in New Issue
Block a user