1999-09-27 18:44:28 +00:00
|
|
|
/*
|
|
|
|
* File: math_inset.C
|
|
|
|
* Purpose: Implementation of insets for mathed
|
2002-03-21 17:42:56 +00:00
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
1999-09-27 18:44:28 +00:00
|
|
|
* Created: January 1996
|
2002-03-21 17:42:56 +00:00
|
|
|
* Description:
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* Dependencies: Xlib, XForms
|
|
|
|
*
|
2000-03-09 03:36:48 +00:00
|
|
|
* Copyright: 1996, 1997 Alejandro Aguilar Sierra
|
1999-09-27 18:44:28 +00:00
|
|
|
*
|
|
|
|
* Version: 0.8beta.
|
|
|
|
*
|
|
|
|
* You are free to use and modify this code under the terms of
|
|
|
|
* the GNU General Public Licence version 2 or later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
2001-02-13 13:28:32 +00:00
|
|
|
#pragma implementation
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|
|
|
|
|
2001-11-07 10:25:05 +00:00
|
|
|
#include <config.h>
|
2001-11-07 08:51:35 +00:00
|
|
|
|
2001-11-07 10:25:05 +00:00
|
|
|
#include "Lsstream.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "math_inset.h"
|
2001-09-11 10:58:17 +00:00
|
|
|
#include "math_scriptinset.h"
|
2001-11-08 12:06:56 +00:00
|
|
|
#include "math_mathmlstream.h"
|
2002-07-08 06:39:40 +00:00
|
|
|
#include "math_cursor.h"
|
2002-07-10 15:23:36 +00:00
|
|
|
#include "math_parser.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "debug.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2002-07-08 06:39:40 +00:00
|
|
|
#include "frontends/LyXView.h"
|
|
|
|
#include "frontends/Dialogs.h"
|
|
|
|
#include "BufferView.h"
|
|
|
|
#include "formulabase.h"
|
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
|
2002-02-16 15:59:55 +00:00
|
|
|
using std::ostream;
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
int MathInset::height() const
|
2001-02-15 12:22:01 +00:00
|
|
|
{
|
2001-08-03 17:55:10 +00:00
|
|
|
return ascent() + descent();
|
2001-02-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-05-24 08:29:16 +00:00
|
|
|
ostream & operator<<(ostream & os, MathAtom const & at)
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2002-03-25 12:11:25 +00:00
|
|
|
WriteStream wi(os, false, false);
|
2002-08-08 17:11:30 +00:00
|
|
|
at->write(wi);
|
2001-06-25 00:06:33 +00:00
|
|
|
return os;
|
2001-02-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
|
2001-09-26 16:52:34 +00:00
|
|
|
MathInset::size_type MathInset::nargs() const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
Dimension MathInset::dimensions() const
|
2002-07-08 16:20:53 +00:00
|
|
|
{
|
2002-07-30 13:56:02 +00:00
|
|
|
lyxerr << "call MathInset::dimensions()\n";
|
|
|
|
return Dimension(width(), ascent(), descent());
|
2002-07-08 16:20:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
MathArray dummyCell;
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
MathArray & MathInset::cell(idx_type)
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-10-24 18:29:55 +00:00
|
|
|
lyxerr << "I don't have a cell 1\n";
|
2001-08-03 17:10:22 +00:00
|
|
|
return dummyCell;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
MathArray const & MathInset::cell(idx_type) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-10-24 18:29:55 +00:00
|
|
|
lyxerr << "I don't have a cell 2\n";
|
2001-08-03 17:10:22 +00:00
|
|
|
return dummyCell;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-12-15 16:13:11 +00:00
|
|
|
MathInset::idx_type MathInset::index(row_type row, col_type col) const
|
|
|
|
{
|
|
|
|
if (row != 0)
|
|
|
|
lyxerr << "illegal row: " << row << "\n";
|
|
|
|
if (col != 0)
|
|
|
|
lyxerr << "illegal col: " << col << "\n";
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-09-11 15:46:51 +00:00
|
|
|
void MathInset::substitute(MathMacro const &)
|
|
|
|
{}
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-09-26 16:52:34 +00:00
|
|
|
bool MathInset::idxNext(idx_type &, pos_type &) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return false;
|
2001-02-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-26 16:52:34 +00:00
|
|
|
bool MathInset::idxRight(idx_type &, pos_type &) const
|
2001-07-06 12:09:32 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return false;
|
2001-07-06 12:09:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-26 16:52:34 +00:00
|
|
|
bool MathInset::idxPrev(idx_type &, pos_type &) const
|
2001-02-15 12:22:01 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return false;
|
2001-02-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-26 16:52:34 +00:00
|
|
|
bool MathInset::idxLeft(idx_type &, pos_type &) const
|
2001-07-06 12:09:32 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return false;
|
2001-07-06 12:09:32 +00:00
|
|
|
}
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
bool MathInset::idxUpDown(idx_type &, pos_type &, bool, int) const
|
2001-02-15 12:22:01 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
return false;
|
2001-02-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-26 16:52:34 +00:00
|
|
|
bool MathInset::idxFirst(idx_type &, pos_type &) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return false;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-09-26 16:52:34 +00:00
|
|
|
bool MathInset::idxLast(idx_type &, pos_type &) const
|
2001-02-15 12:22:01 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return false;
|
2001-02-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
|
2001-03-01 19:57:01 +00:00
|
|
|
|
2001-09-26 16:52:34 +00:00
|
|
|
bool MathInset::idxHome(idx_type &, pos_type &) const
|
2001-03-01 19:57:01 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return false;
|
2001-03-01 19:57:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-09-26 16:52:34 +00:00
|
|
|
bool MathInset::idxEnd(idx_type &, pos_type &) const
|
2001-03-01 19:57:01 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return false;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-16 18:22:45 +00:00
|
|
|
void MathInset::getPos(idx_type, pos_type, int & x, int & y) const
|
|
|
|
{
|
|
|
|
lyxerr << "MathInset::getPos() called directly!\n";
|
|
|
|
x = y = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
void MathInset::dump() const
|
|
|
|
{
|
|
|
|
lyxerr << "---------------------------------------------\n";
|
2002-03-25 12:11:25 +00:00
|
|
|
WriteStream wi(lyxerr, false, true);
|
2001-10-19 11:25:48 +00:00
|
|
|
write(wi);
|
2001-08-03 17:10:22 +00:00
|
|
|
lyxerr << "\n---------------------------------------------\n";
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-02 13:35:05 +00:00
|
|
|
bool MathInset::idxBetween(idx_type idx, idx_type from, idx_type to) const
|
2001-07-16 15:53:25 +00:00
|
|
|
{
|
2002-08-02 13:35:05 +00:00
|
|
|
return from <= idx && idx <= to;
|
2001-07-16 15:53:25 +00:00
|
|
|
}
|
2001-08-03 09:54:48 +00:00
|
|
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
void MathInset::metrics(MathMetricsInfo &) const
|
2001-08-03 17:55:10 +00:00
|
|
|
{
|
2001-08-07 08:40:14 +00:00
|
|
|
lyxerr << "MathInset::metrics() called directly!\n";
|
2001-08-03 17:55:10 +00:00
|
|
|
}
|
2001-08-06 17:20:26 +00:00
|
|
|
|
|
|
|
|
2002-05-30 07:09:54 +00:00
|
|
|
void MathInset::draw(MathPainterInfo &, int, int) const
|
2001-08-06 17:20:26 +00:00
|
|
|
{
|
|
|
|
lyxerr << "MathInset::draw() called directly!\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-26 17:23:44 +00:00
|
|
|
void MathInset::drawSelection(MathPainterInfo &,
|
|
|
|
idx_type, pos_type, idx_type, pos_type) const
|
|
|
|
{
|
|
|
|
lyxerr << "MathInset::drawSelection() called directly!\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 06:57:13 +00:00
|
|
|
void MathInset::metricsT(TextMetricsInfo const &) const
|
2002-03-18 11:45:53 +00:00
|
|
|
{
|
2002-04-08 08:12:09 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
2002-03-21 06:57:13 +00:00
|
|
|
lyxerr << "MathInset::metricsT(Text) called directly!\n";
|
2002-04-08 08:12:09 +00:00
|
|
|
#endif
|
2002-03-18 11:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-03-21 06:57:13 +00:00
|
|
|
void MathInset::drawT(TextPainter &, int, int) const
|
2002-03-18 11:45:53 +00:00
|
|
|
{
|
2002-04-08 08:12:09 +00:00
|
|
|
#ifdef WITH_WARNINGS
|
2002-03-21 06:57:13 +00:00
|
|
|
lyxerr << "MathInset::drawT(Text) called directly!\n";
|
2002-04-08 08:12:09 +00:00
|
|
|
#endif
|
2002-03-18 11:45:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-08-05 07:09:11 +00:00
|
|
|
void MathInset::write(WriteStream & os) const
|
|
|
|
{
|
|
|
|
os << '\\' << name().c_str() << ' ';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathInset::normalize(NormalStream & os) const
|
2001-08-06 17:20:26 +00:00
|
|
|
{
|
2002-08-05 07:09:11 +00:00
|
|
|
os << '[' << name().c_str() << "] ";
|
2001-08-06 17:20:26 +00:00
|
|
|
}
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
void MathInset::octavize(OctaveStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream ns(os.os());
|
2001-11-09 08:35:57 +00:00
|
|
|
normalize(ns);
|
2001-11-07 08:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
void MathInset::maplize(MapleStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream ns(os.os());
|
2001-11-09 08:35:57 +00:00
|
|
|
normalize(ns);
|
2001-11-07 08:51:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-01 11:17:14 +00:00
|
|
|
void MathInset::mathematicize(MathematicaStream & os) const
|
|
|
|
{
|
|
|
|
NormalStream ns(os.os());
|
|
|
|
normalize(ns);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-11-07 17:30:26 +00:00
|
|
|
void MathInset::mathmlize(MathMLStream & os) const
|
2001-11-07 08:51:35 +00:00
|
|
|
{
|
2001-12-03 16:24:50 +00:00
|
|
|
NormalStream ns(os.os());
|
2001-11-09 08:35:57 +00:00
|
|
|
normalize(ns);
|
2001-11-07 08:51:35 +00:00
|
|
|
}
|
2002-06-24 15:37:14 +00:00
|
|
|
|
|
|
|
|
|
|
|
int MathInset::ascii(std::ostream &, int) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathInset::linuxdoc(std::ostream &) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathInset::docbook(std::ostream &, bool) const
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-13 17:43:40 +00:00
|
|
|
MathInset::result_type
|
|
|
|
MathInset::dispatch(FuncRequest const &, idx_type &, pos_type &)
|
2002-06-24 15:37:14 +00:00
|
|
|
{
|
2002-08-13 17:43:40 +00:00
|
|
|
return UNDISPATCHED;
|
2002-06-24 15:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-07-08 06:39:40 +00:00
|
|
|
string const & MathInset::getType() const
|
|
|
|
{
|
|
|
|
static string t("none");
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-08-01 15:53:46 +00:00
|
|
|
string MathInset::name() const
|
|
|
|
{
|
|
|
|
return "unknown";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-24 15:37:14 +00:00
|
|
|
string asString(MathArray const & ar)
|
|
|
|
{
|
2002-07-10 15:23:36 +00:00
|
|
|
std::ostringstream os;
|
|
|
|
WriteStream ws(os);
|
|
|
|
ws << ar;
|
|
|
|
return os.str();
|
2002-06-24 15:37:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MathArray asArray(string const & str)
|
|
|
|
{
|
|
|
|
MathArray ar;
|
2002-07-10 15:23:36 +00:00
|
|
|
mathed_parse_cell(ar, str);
|
2002-06-24 15:37:14 +00:00
|
|
|
return ar;
|
|
|
|
}
|
2002-07-08 06:39:40 +00:00
|
|
|
|
|
|
|
|
2002-08-13 14:40:38 +00:00
|
|
|
Dialogs & getDialogs()
|
2002-07-08 06:39:40 +00:00
|
|
|
{
|
|
|
|
return mathcursor->formula()->view()->owner()->getDialogs();
|
|
|
|
}
|