1999-09-27 18:44:28 +00:00
|
|
|
/*
|
|
|
|
* File: math_inset.C
|
|
|
|
* Purpose: Implementation of insets for mathed
|
|
|
|
* Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
|
|
|
|
* Created: January 1996
|
|
|
|
* Description:
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
|
|
|
|
#include "math_inset.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "debug.h"
|
2001-02-13 13:28:32 +00:00
|
|
|
|
2001-02-28 11:56:36 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
int MathInset::workwidth;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
2001-08-08 17:26:30 +00:00
|
|
|
MathInset::MathInset()
|
|
|
|
: size_(LM_ST_DISPLAY), code_(LM_TC_MIN), xo_(0), yo_(0)
|
2001-02-28 11:56:36 +00:00
|
|
|
{}
|
1999-09-27 18:44:28 +00:00
|
|
|
|
1999-11-24 22:14:46 +00:00
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
MathStyles MathInset::size() const
|
2001-02-15 12:22:01 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
return size_;
|
2001-02-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-06 17:20:26 +00:00
|
|
|
void MathInset::size(MathStyles s) const
|
2001-02-15 12:22:01 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
size_ = s;
|
|
|
|
}
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
std::ostream & operator<<(std::ostream & os, MathInset const & inset)
|
|
|
|
{
|
2001-07-26 06:56:43 +00:00
|
|
|
inset.write(os, false);
|
2001-06-25 00:06:33 +00:00
|
|
|
return os;
|
2001-02-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
int MathInset::xo() const
|
2001-02-15 12:22:01 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
return xo_;
|
2001-02-15 12:22:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
int MathInset::yo() const
|
|
|
|
{
|
|
|
|
return yo_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-06 17:20:26 +00:00
|
|
|
void MathInset::xo(int x) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
xo_ = x;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-06 17:20:26 +00:00
|
|
|
void MathInset::yo(int y) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
yo_ = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int MathInset::nargs() const
|
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
return 0;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
MathXArray dummyCell;
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
MathXArray & MathInset::xcell(int)
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
lyxerr << "I don't have a cell\n";
|
|
|
|
return dummyCell;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
MathXArray const & MathInset::xcell(int) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
lyxerr << "I don't have a cell\n";
|
|
|
|
return dummyCell;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
MathArray & MathInset::cell(int)
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
lyxerr << "I don't have a cell\n";
|
|
|
|
return dummyCell.data_;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
MathArray const & MathInset::cell(int) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
lyxerr << "I don't have a cell\n";
|
|
|
|
return dummyCell.data_;
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
void MathInset::substitute(MathArray & array, MathMacro const &) const
|
2001-02-15 12:22:01 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
array.push_back(clone());
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
bool MathInset::idxNext(int &, int &) 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-08-03 17:10:22 +00:00
|
|
|
bool MathInset::idxRight(int &, int &) 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 17:10:22 +00:00
|
|
|
bool MathInset::idxPrev(int &, int &) 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-08-03 17:10:22 +00:00
|
|
|
bool MathInset::idxLeft(int &, int &) 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
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
bool MathInset::idxUp(int &, int &) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2001-02-15 12:22:01 +00:00
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
bool MathInset::idxDown(int &, 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-08-03 17:10:22 +00:00
|
|
|
bool MathInset::idxFirst(int &, int &) 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-08-03 17:10:22 +00:00
|
|
|
bool MathInset::idxLast(int &, int &) 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-08-03 17:10:22 +00:00
|
|
|
bool MathInset::idxHome(int &, int &) 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-08-03 17:10:22 +00:00
|
|
|
bool MathInset::idxEnd(int &, int &) 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
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
bool MathInset::idxFirstUp(int &, int &) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathInset::idxFirstDown(int &, int &) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-07-09 16:59:57 +00:00
|
|
|
void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
|
2001-06-27 14:10:35 +00:00
|
|
|
{
|
2001-07-09 16:59:57 +00:00
|
|
|
popit = false;
|
|
|
|
deleteit = false;
|
2001-06-27 14:10:35 +00:00
|
|
|
}
|
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-07-16 15:53:25 +00:00
|
|
|
void MathInset::idxDeleteRange(int, int)
|
|
|
|
{}
|
|
|
|
|
2001-06-27 14:10:35 +00:00
|
|
|
|
|
|
|
bool MathInset::idxLastUp(int &, int &) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathInset::idxLastDown(int &, int &) const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathInset::getXY(int & x, int & y) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
x = xo();
|
|
|
|
y = yo();
|
2001-03-01 19:57:01 +00:00
|
|
|
}
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
/*
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathInset::userSetSize(MathStyles sz)
|
2001-03-01 19:57:01 +00:00
|
|
|
{
|
2001-06-25 00:06:33 +00:00
|
|
|
if (sz >= 0) {
|
|
|
|
size_ = sz;
|
|
|
|
flag = flag & ~LMPF_FIXED_SIZE;
|
|
|
|
}
|
2001-03-01 19:57:01 +00:00
|
|
|
}
|
2001-06-25 00:06:33 +00:00
|
|
|
*/
|
|
|
|
|
2001-07-26 06:56:43 +00:00
|
|
|
void MathInset::writeNormal(std::ostream & os) const
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-08 17:26:30 +00:00
|
|
|
os << "[unknown] ";
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathInset::dump() const
|
|
|
|
{
|
|
|
|
lyxerr << "---------------------------------------------\n";
|
2001-07-26 06:56:43 +00:00
|
|
|
write(lyxerr, false);
|
2001-08-03 17:10:22 +00:00
|
|
|
lyxerr << "\n---------------------------------------------\n";
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
void MathInset::push_back(unsigned char, MathTextCodes)
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
lyxerr << "can't push without a cell\n";
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-08-03 17:55:10 +00:00
|
|
|
void MathInset::push_back(MathInset *)
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
2001-08-03 17:10:22 +00:00
|
|
|
lyxerr << "can't push without a cell\n";
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool MathInset::covers(int x, int y) const
|
|
|
|
{
|
|
|
|
return
|
|
|
|
x >= xo_ &&
|
2001-08-03 17:55:10 +00:00
|
|
|
x <= xo_ + width() &&
|
|
|
|
y >= yo_ - ascent() &&
|
|
|
|
y <= yo_ + descent();
|
2001-06-25 00:06:33 +00:00
|
|
|
}
|
2001-07-13 14:54:56 +00:00
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
void MathInset::validate(LaTeXFeatures &) const
|
|
|
|
{}
|
2001-07-16 15:53:25 +00:00
|
|
|
|
2001-08-03 09:54:48 +00:00
|
|
|
|
2001-07-16 15:53:25 +00:00
|
|
|
std::vector<int> MathInset::idxBetween(int from, int to) const
|
|
|
|
{
|
|
|
|
std::vector<int> res;
|
|
|
|
for (int i = from; i <= to; ++i)
|
|
|
|
res.push_back(i);
|
|
|
|
return res;
|
|
|
|
}
|
2001-08-03 09:54:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
MathTextCodes MathInset::code() const
|
|
|
|
{
|
|
|
|
return code_;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathInset::code(MathTextCodes t)
|
|
|
|
{
|
|
|
|
code_ = t;
|
|
|
|
}
|
2001-08-03 17:55:10 +00:00
|
|
|
|
|
|
|
|
2001-08-06 17:20:26 +00:00
|
|
|
void MathInset::metrics(MathStyles st) 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
|
|
|
size_ = st;
|
|
|
|
}
|
2001-08-06 17:20:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
void MathInset::draw(Painter &, int, int) const
|
|
|
|
{
|
|
|
|
lyxerr << "MathInset::draw() called directly!\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void MathInset::write(std::ostream &, bool) const
|
|
|
|
{
|
|
|
|
lyxerr << "MathInset::write() called directly!\n";
|
|
|
|
}
|