mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 03:11:59 +00:00
fix some fbox drawing
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8903 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a5d39ee28e
commit
25b1956b2a
@ -25,6 +25,8 @@ libmathed_la_SOURCES = \
|
||||
math_boldsymbolinset.h \
|
||||
math_boxinset.C \
|
||||
math_boxinset.h \
|
||||
math_boxedinset.C \
|
||||
math_boxedinset.h \
|
||||
math_braceinset.C \
|
||||
math_braceinset.h \
|
||||
math_casesinset.C \
|
||||
|
77
src/mathed/math_boxedinset.C
Normal file
77
src/mathed/math_boxedinset.C
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
* \file math_boxedinset.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_boxedinset.h"
|
||||
#include "math_data.h"
|
||||
#include "math_mathmlstream.h"
|
||||
#include "math_parser.h"
|
||||
#include "math_streamstr.h"
|
||||
#include "LaTeXFeatures.h"
|
||||
#include "LColor.h"
|
||||
|
||||
#include "support/std_ostream.h"
|
||||
#include "frontends/Painter.h"
|
||||
|
||||
using std::auto_ptr;
|
||||
|
||||
|
||||
MathBoxedInset::MathBoxedInset()
|
||||
: MathNestInset(1)
|
||||
{}
|
||||
|
||||
|
||||
auto_ptr<InsetBase> MathBoxedInset::clone() const
|
||||
{
|
||||
return auto_ptr<InsetBase>(new MathBoxedInset(*this));
|
||||
}
|
||||
|
||||
|
||||
void MathBoxedInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
cell(0).metrics(mi, dim);
|
||||
metricsMarkers2(dim, 3); // 1 pixel space, 1 frame, 1 space
|
||||
dim_ = dim;
|
||||
}
|
||||
|
||||
|
||||
void MathBoxedInset::draw(PainterInfo & pi, int x, int y) const
|
||||
{
|
||||
pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
|
||||
dim_.width() - 2, dim_.height() - 2, LColor::foreground);
|
||||
cell(0).draw(pi, x + 3, y);
|
||||
setPosCache(pi, x, y);
|
||||
}
|
||||
|
||||
|
||||
void MathBoxedInset::write(WriteStream & os) const
|
||||
{
|
||||
os << "\\boxed{" << cell(0) << '}';
|
||||
}
|
||||
|
||||
|
||||
void MathBoxedInset::normalize(NormalStream & os) const
|
||||
{
|
||||
os << "[boxed " << cell(0) << ']';
|
||||
}
|
||||
|
||||
|
||||
void MathBoxedInset::infoize(std::ostream & os) const
|
||||
{
|
||||
os << "Boxed: ";
|
||||
}
|
||||
|
||||
|
||||
void MathBoxedInset::validate(LaTeXFeatures & features) const
|
||||
{
|
||||
features.require("amsmath");
|
||||
}
|
||||
|
39
src/mathed/math_boxedinset.h
Normal file
39
src/mathed/math_boxedinset.h
Normal file
@ -0,0 +1,39 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file math_boxedinset.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_BOXEDINSET_H
|
||||
#define MATH_BOXEDINSET_H
|
||||
|
||||
#include "math_nestinset.h"
|
||||
|
||||
|
||||
/// Non-AMS-style frame
|
||||
class MathBoxedInset : public MathNestInset {
|
||||
public:
|
||||
///
|
||||
MathBoxedInset();
|
||||
///
|
||||
std::auto_ptr<InsetBase> clone() const;
|
||||
///
|
||||
void validate(LaTeXFeatures & features) const;
|
||||
///
|
||||
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
||||
///
|
||||
void draw(PainterInfo & pi, int x, int y) const;
|
||||
///
|
||||
void write(WriteStream & os) const;
|
||||
/// write normalized content
|
||||
void normalize(NormalStream & ns) const;
|
||||
///
|
||||
void infoize(std::ostream & os) const;
|
||||
};
|
||||
|
||||
#endif
|
@ -16,6 +16,7 @@
|
||||
#include "math_amsarrayinset.h"
|
||||
#include "math_binominset.h"
|
||||
#include "math_boxinset.h"
|
||||
#include "math_boxedinset.h"
|
||||
#include "math_boldsymbolinset.h"
|
||||
#include "math_casesinset.h"
|
||||
#include "math_colorinset.h"
|
||||
@ -275,6 +276,8 @@ MathAtom createMathInset(string const & s)
|
||||
if (s.size() == 3 && s[0] == '\\' && s[1] == '#'
|
||||
&& s[2] >= '1' && s[2] <= '9')
|
||||
return MathAtom(new MathMacroArgument(s[2] - '0'));
|
||||
if (s == "boxed")
|
||||
return MathAtom(new MathBoxedInset());
|
||||
if (s == "mbox")
|
||||
return MathAtom(new MathBoxInset("mbox"));
|
||||
if (s == "fbox")
|
||||
|
@ -44,7 +44,7 @@ void MathFboxInset::metrics(MetricsInfo & mi, Dimension & dim) const
|
||||
{
|
||||
FontSetChanger dummy(mi.base, "textnormal");
|
||||
cell(0).metrics(mi, dim);
|
||||
metricsMarkers(dim, 5); // 5 pixels margin
|
||||
metricsMarkers(dim, 3); // 1 pixel space, 1 frame, 1 space
|
||||
dim_ = dim;
|
||||
}
|
||||
|
||||
@ -54,7 +54,7 @@ void MathFboxInset::draw(PainterInfo & pi, int x, int y) const
|
||||
pi.pain.rectangle(x + 1, y - dim_.ascent() + 1,
|
||||
dim_.width() - 2, dim_.height() - 2, LColor::foreground);
|
||||
FontSetChanger dummy(pi.base, "textnormal");
|
||||
cell(0).draw(pi, x + 5, y);
|
||||
cell(0).draw(pi, x + 3, y);
|
||||
setPosCache(pi, x, y);
|
||||
}
|
||||
|
||||
|
@ -15,9 +15,7 @@
|
||||
#include "math_nestinset.h"
|
||||
|
||||
|
||||
class latexkeys;
|
||||
|
||||
/// Extra nesting
|
||||
/// Non-AMS-style frame
|
||||
class MathFboxInset : public MathNestInset {
|
||||
public:
|
||||
///
|
||||
|
@ -144,8 +144,7 @@ enum {
|
||||
FLAG_EQUATION = 1 << 9, // next \] leaves the loop
|
||||
FLAG_SIMPLE2 = 1 << 10, // next \) leaves the loop
|
||||
FLAG_OPTION = 1 << 11, // read [...] style option
|
||||
FLAG_BRACED = 1 << 12, // read {...} style argument
|
||||
FLAG_SKIPSPACE = 1 << 13 // skip spaces
|
||||
FLAG_BRACED = 1 << 12 // read {...} style argument
|
||||
};
|
||||
|
||||
|
||||
@ -585,14 +584,6 @@ void Parser::parse1(MathGridInset & grid, unsigned flags,
|
||||
lyxerr << endl;
|
||||
#endif
|
||||
|
||||
if (flags & FLAG_SKIPSPACE) {
|
||||
if (t.cat() == catSpace || t.cat() == catNewline)
|
||||
continue;
|
||||
pop_back();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (flags & FLAG_ITEM) {
|
||||
|
||||
if (t.cat() == catBegin) {
|
||||
|
@ -305,12 +305,12 @@ bool MathScriptInset::hasLimits() const
|
||||
|
||||
void MathScriptInset::removeScript(bool up)
|
||||
{
|
||||
lyxerr << "MathNestInset::removeScript: 1 up: " << up << endl;
|
||||
lyxerr << "MathScriptInset::removeScript: 1 up: " << up << endl;
|
||||
if (nargs() == 2) {
|
||||
lyxerr << "MathNestInset::removeScript: a up: " << up << endl;
|
||||
lyxerr << "MathScriptInset::removeScript: a up: " << up << endl;
|
||||
if (up == cell_1_is_up_)
|
||||
cells_.pop_back();
|
||||
lyxerr << "MathNestInset::removeScript: b up: " << up << endl;
|
||||
lyxerr << "MathScriptInset::removeScript: b up: " << up << endl;
|
||||
} else if (nargs() == 3) {
|
||||
if (up == true) {
|
||||
swap(cells_[1], cells_[2]);
|
||||
@ -320,7 +320,7 @@ void MathScriptInset::removeScript(bool up)
|
||||
}
|
||||
cells_.pop_back();
|
||||
}
|
||||
lyxerr << "MathNestInset::removeScript: 2 up: " << up << endl;
|
||||
lyxerr << "MathScriptInset::removeScript: 2 up: " << up << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -557,22 +557,22 @@ void MathScriptInset::notifyCursorLeaves(LCursor & cur)
|
||||
{
|
||||
MathNestInset::notifyCursorLeaves(cur);
|
||||
|
||||
lyxerr << "MathScriptInset::notifyCursorLeaves: 1 " << cur << endl;
|
||||
|
||||
// remove empty scripts if possible
|
||||
if (0) {
|
||||
if (nargs() > 2 && cur.idx() == 2 && cell(2).empty()) {
|
||||
// must be a subscript...
|
||||
removeScript(false);
|
||||
// sanitize cursor, even if this slice will be removed immediately
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
} else if (nargs() > 1 && cur.idx() == 1 && cell(1).empty()) {
|
||||
// could be either subscript or super script
|
||||
removeScript(cell_1_is_up_);
|
||||
// sanitize cursor, even if this slice will be removed immediately
|
||||
cur.idx() = 0;
|
||||
cur.pos() = 0;
|
||||
}
|
||||
}
|
||||
|
||||
lyxerr << "MathScriptInset::notifyCursorLeaves: 2 " << cur << endl;
|
||||
}
|
||||
|
||||
|
||||
void MathScriptInset::priv_dispatch(LCursor & cur, FuncRequest & cmd)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user