#include "InsetMathArray.h"
#include "InsetMathChar.h"
#include "InsetMathColor.h"
-#include "MathArray.h"
+#include "MathData.h"
#include "InsetMathDelim.h"
#include "MathExtern.h"
#include "MathFactory.h"
#include "InsetMathRef.h"
#include "bufferview_funcs.h"
-#include "LyXText.h"
+#include "Text.h"
#include "Buffer.h"
#include "BufferParams.h"
#include "BufferView.h"
#include "CutAndPaste.h"
#include "FuncStatus.h"
-#include "LColor.h"
+#include "Color.h"
#include "LaTeXFeatures.h"
-#include "LCursor.h"
+#include "Cursor.h"
#include "debug.h"
#include "DispatchResult.h"
#include "FuncRequest.h"
#include "graphics/PreviewImage.h"
#include "graphics/PreviewLoader.h"
+#include "frontends/Painter.h"
+
#include "support/lyxlib.h"
#include "support/lstrings.h"
// returns position of first relation operator in the array
// used for "intelligent splitting"
- size_t firstRelOp(MathArray const & ar)
+ size_t firstRelOp(MathData const & ar)
{
- for (MathArray::const_iterator it = ar.begin(); it != ar.end(); ++it)
+ for (MathData::const_iterator it = ar.begin(); it != ar.end(); ++it)
if ((*it)->isRelOp())
return it - ar.begin();
return ar.size();
//lyxerr << "sizeof InsetMath: " << sizeof(InsetMath) << endl;
//lyxerr << "sizeof MetricsInfo: " << sizeof(MetricsInfo) << endl;
//lyxerr << "sizeof InsetMathChar: " << sizeof(InsetMathChar) << endl;
- //lyxerr << "sizeof LyXFont: " << sizeof(LyXFont) << endl;
+ //lyxerr << "sizeof Font: " << sizeof(Font) << endl;
initMath();
setDefaults();
}
InsetMathHull::InsetMathHull(InsetMathHull const & other)
: InsetMathGrid(other),
type_(other.type_), nonum_(other.nonum_), label_(other.label_),
- preview_(new RenderPreview(this))
+ preview_(new RenderPreview(*other.preview_, this))
{}
{}
-auto_ptr<InsetBase> InsetMathHull::doClone() const
+auto_ptr<Inset> InsetMathHull::doClone() const
{
- return auto_ptr<InsetBase>(new InsetMathHull(*this));
+ return auto_ptr<Inset>(new InsetMathHull(*this));
}
}
-InsetBase * InsetMathHull::editXY(LCursor & cur, int x, int y)
+Inset * InsetMathHull::editXY(Cursor & cur, int x, int y)
{
if (use_preview_) {
edit(cur, true);
}
-bool InsetMathHull::idxFirst(LCursor & cur) const
+bool InsetMathHull::idxFirst(Cursor & cur) const
{
cur.idx() = 0;
cur.pos() = 0;
}
-bool InsetMathHull::idxLast(LCursor & cur) const
+bool InsetMathHull::idxLast(Cursor & cur) const
{
cur.idx() = nargs() - 1;
cur.pos() = cur.lastpos();
{
if (!editing(bv) && RenderPreview::status() == LyXRC::PREVIEW_ON) {
graphics::PreviewImage const * pimage =
- preview_->getPreviewImage(*bv->buffer());
+ preview_->getPreviewImage(bv->buffer());
return pimage && pimage->image();
}
return false;
{
use_preview_ = previewState(pi.base.bv);
+ // background of mathed under focus is not painted because
+ // selection at the top level of nested inset is difficult to handle.
+ if (!editing(pi.base.bv))
+ pi.pain.fillRectangle(x + 1, y - ascent() + 1, width() - 2,
+ ascent() + descent() - 1, Color::mathbg);
+
if (use_preview_) {
// one pixel gap in front
preview_->draw(pi, x + 1, y);
}
-bool InsetMathHull::notifyCursorLeaves(LCursor & cur)
+bool InsetMathHull::notifyCursorLeaves(Cursor & cur)
{
if (RenderPreview::status() == LyXRC::PREVIEW_ON) {
Buffer const & buffer = cur.buffer();
}
-bool InsetMathHull::display() const
+Inset::DisplayType InsetMathHull::display() const
{
- return type_ != hullSimple && type_ != hullNone;
+ return (type_ != hullSimple && type_ != hullNone) ? AlignCenter : Inline;
}
void InsetMathHull::glueall()
{
- MathArray ar;
+ MathData ar;
for (idx_type i = 0; i < nargs(); ++i)
ar.append(cell(i));
*this = InsetMathHull(hullSimple);
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 2 * row;
pos_type pos = firstRelOp(cell(i));
- cell(i + 1) = MathArray(cell(i).begin() + pos, cell(i).end());
+ cell(i + 1) = MathData(cell(i).begin() + pos, cell(i).end());
cell(i).erase(pos, cell(i).size());
}
}
for (row_type row = 0; row < nrows(); ++row) {
idx_type const i = 3 * row + 1;
if (cell(i).size()) {
- cell(i + 1) = MathArray(cell(i).begin() + 1, cell(i).end());
+ cell(i + 1) = MathData(cell(i).begin() + 1, cell(i).end());
cell(i).erase(1, cell(i).size());
}
}
}
-void InsetMathHull::doExtern(LCursor & cur, FuncRequest & func)
+void InsetMathHull::doExtern(Cursor & cur, FuncRequest & func)
{
docstring dlang;
docstring extra;
extra = from_ascii("noextra");
std::string const lang = to_ascii(dlang);
-#ifdef WITH_WARNINGS
-#warning temporarily disabled
+ // FIXME: temporarily disabled
//if (cur.selection()) {
- // MathArray ar;
+ // MathData ar;
// selGet(cur.ar);
// lyxerr << "use selection: " << ar << endl;
// insert(pipeThroughExtern(lang, extra, ar));
// return;
//}
-#endif
- MathArray eq;
+ MathData eq;
eq.push_back(MathAtom(new InsetMathChar('=')));
// go to first item in line
if (getType() == hullSimple) {
size_type pos = cur.cell().find_last(eq);
- MathArray ar;
+ MathData ar;
if (cur.inMathed() && cur.selection()) {
asArray(grabAndEraseSelection(cur), ar);
} else if (pos == cur.cell().size()) {
ar = cur.cell();
lyxerr << "use whole cell: " << ar << endl;
} else {
- ar = MathArray(cur.cell().begin() + pos + 1, cur.cell().end());
+ ar = MathData(cur.cell().begin() + pos + 1, cur.cell().end());
lyxerr << "use partial cell form pos: " << pos << endl;
}
cur.cell().append(eq);
if (getType() == hullEquation) {
lyxerr << "use equation inset" << endl;
mutate(hullEqnArray);
- MathArray & ar = cur.cell();
+ MathData & ar = cur.cell();
lyxerr << "use cell: " << ar << endl;
++cur.idx();
cur.cell() = eq;
lyxerr << "use eqnarray" << endl;
cur.idx() += 2 - cur.idx() % ncols();
cur.pos() = 0;
- MathArray ar = cur.cell();
+ MathData ar = cur.cell();
lyxerr << "use cell: " << ar << endl;
-#ifdef WITH_WARNINGS
-#warning temporarily disabled
-#endif
+ // FIXME: temporarily disabled
addRow(cur.row());
++cur.idx();
++cur.idx();
}
-void InsetMathHull::doDispatch(LCursor & cur, FuncRequest & cmd)
+void InsetMathHull::doDispatch(Cursor & cur, FuncRequest & cmd)
{
//lyxerr << "action: " << cmd.action << endl;
switch (cmd.action) {
case LFUN_FINISHED_LEFT:
case LFUN_FINISHED_RIGHT:
- case LFUN_FINISHED_UP:
- case LFUN_FINISHED_DOWN:
//lyxerr << "action: " << cmd.action << endl;
InsetMathGrid::doDispatch(cur, cmd);
notifyCursorLeaves(cur);
if (type_ == hullSimple || type_ == hullEquation) {
recordUndoInset(cur);
bool const align =
- cur.bv().buffer()->params().use_amsmath == BufferParams::package_on;
+ cur.bv().buffer().params().use_amsmath == BufferParams::package_on;
mutate(align ? hullAlign : hullEqnArray);
cur.idx() = 0;
cur.pos() = cur.lastpos();
numbered(r, true);
docstring old = label(r);
if (str != old) {
- cur.bv().buffer()->changeRefsIfUnique(old, str,
- InsetBase::REF_CODE);
+ cur.bv().buffer().changeRefsIfUnique(old, str,
+ Inset::REF_CODE);
label(r, str);
}
break;
}
-bool InsetMathHull::getStatus(LCursor & cur, FuncRequest const & cmd,
+bool InsetMathHull::getStatus(Cursor & cur, FuncRequest const & cmd,
FuncStatus & status) const
{
switch (cmd.action) {
case LFUN_FINISHED_LEFT:
case LFUN_FINISHED_RIGHT:
- case LFUN_FINISHED_UP:
- case LFUN_FINISHED_DOWN:
+ case LFUN_UP:
+ case LFUN_DOWN:
status.enabled(true);
return true;
case LFUN_BREAK_LINE:
string str = os.str();
// insert this text
- LyXText * lt = view_->cursor().innerText();
+ Text * lt = view_->cursor().innerText();
string::const_iterator cit = str.begin();
string::const_iterator end = str.end();
for (; cit != end; ++cit)
}
-void InsetMathHull::handleFont(LCursor & cur, docstring const & arg,
+void InsetMathHull::handleFont(Cursor & cur, docstring const & arg,
docstring const & font)
{
// this whole function is a hack and won't work for incremental font
}
-void InsetMathHull::handleFont2(LCursor & cur, docstring const & arg)
+void InsetMathHull::handleFont2(Cursor & cur, docstring const & arg)
{
recordUndo(cur);
- LyXFont font;
+ Font font;
bool b;
bv_funcs::string2font(to_utf8(arg), font, b);
- if (font.color() != LColor::inherit) {
+ if (font.color() != Color::inherit) {
MathAtom at = MathAtom(new InsetMathColor(true, font.color()));
cur.handleNest(at, 0);
}
}
-void InsetMathHull::edit(LCursor & cur, bool left)
+void InsetMathHull::edit(Cursor & cur, bool left)
{
cur.push(*this);
left ? idxFirst(cur) : idxLast(cur);
// The inset formula dimension is not necessarily the same as the
// one of the instant preview image, so we have to indicate to the
- // BufferView that a metrics update is needed.
+ // BufferView that a metrics update is needed.
cur.updateFlags(Update::Force);
}
}
-void InsetMathHull::revealCodes(LCursor & cur) const
+void InsetMathHull::revealCodes(Cursor & cur) const
{
if (!cur.inMathed())
return;
}
-InsetBase::Code InsetMathHull::lyxCode() const
+Inset::Code InsetMathHull::lyxCode() const
{
return MATH_CODE;
}
bool InsetMathHull::searchForward(BufferView * bv, string const & str,
bool, bool)
{
-#ifdef WITH_WARNINGS
-#warning completely broken
-#endif
+ // FIXME: completely broken
static InsetMathHull * lastformula = 0;
static CursorBase current = DocIterator(ibegin(nucleus()));
- static MathArray ar;
+ static MathData ar;
static string laststr;
if (lastformula != this || laststr != str) {
for (DocIterator it = current; it != iend(nucleus()); increment(it)) {
CursorSlice & top = it.back();
- MathArray const & a = top.asInsetMath()->cell(top.idx_);
+ MathData const & a = top.asInsetMath()->cell(top.idx_);
if (a.matchpart(ar, top.pos_)) {
bv->cursor().setSelection(it, ar.size());
current = it;
int InsetMathHull::plaintext(Buffer const &, odocstream & os,
- OutputParams const &) const
+ OutputParams const &) const
{
if (0 && display()) {
Dimension dim;
int InsetMathHull::docbook(Buffer const & buf, odocstream & os,
- OutputParams const & runparams) const
+ OutputParams const & runparams) const
{
MathStream ms(os);
int res = 0;