3 * Purpose: Implementation of insets for mathed
4 * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
5 * Created: January 1996
8 * Dependencies: Xlib, XForms
10 * Copyright: 1996, 1997 Alejandro Aguilar Sierra
14 * You are free to use and modify this code under the terms of
15 * the GNU General Public Licence version 2 or later.
19 #pragma implementation
22 #include "math_inset.h"
26 int MathInset::workwidth;
29 MathInset::MathInset(string const & name)
30 : name_(name), size_(LM_ST_DISPLAY), code_(LM_TC_MIN), xo_(0), yo_(0)
34 int MathInset::height() const
36 return ascent() + descent();
40 string const & MathInset::name() const
46 void MathInset::setName(string const & n)
52 MathStyles MathInset::size() const
58 void MathInset::size(MathStyles s) const
64 std::ostream & operator<<(std::ostream & os, MathInset const & inset)
66 inset.write(os, false);
71 int MathInset::xo() const
77 int MathInset::yo() const
83 void MathInset::xo(int x) const
89 void MathInset::yo(int y) const
95 int MathInset::nargs() const
101 MathXArray dummyCell;
103 MathXArray & MathInset::xcell(int)
105 lyxerr << "I don't have a cell\n";
110 MathXArray const & MathInset::xcell(int) const
112 lyxerr << "I don't have a cell\n";
117 MathArray & MathInset::cell(int)
119 lyxerr << "I don't have a cell\n";
120 return dummyCell.data_;
124 MathArray const & MathInset::cell(int) const
126 lyxerr << "I don't have a cell\n";
127 return dummyCell.data_;
131 void MathInset::substitute(MathArray & array, MathMacro const &) const
133 array.push_back(clone());
137 bool MathInset::idxNext(int &, int &) const
143 bool MathInset::idxRight(int &, int &) const
149 bool MathInset::idxPrev(int &, int &) const
155 bool MathInset::idxLeft(int &, int &) const
161 bool MathInset::idxUp(int &, int &) const
167 bool MathInset::idxDown(int &, int &) const
173 bool MathInset::idxFirst(int &, int &) const
179 bool MathInset::idxLast(int &, int &) const
185 bool MathInset::idxHome(int &, int &) const
191 bool MathInset::idxEnd(int &, int &) const
197 bool MathInset::idxFirstUp(int &, int &) const
203 bool MathInset::idxFirstDown(int &, int &) const
209 void MathInset::idxDelete(int &, bool & popit, bool & deleteit)
216 void MathInset::idxDeleteRange(int, int)
220 bool MathInset::idxLastUp(int &, int &) const
226 bool MathInset::idxLastDown(int &, int &) const
232 void MathInset::getXY(int & x, int & y) const
240 void MathInset::userSetSize(MathStyles sz)
244 flag = flag & ~LMPF_FIXED_SIZE;
249 void MathInset::writeNormal(std::ostream & os) const
251 os << "[" << name_ << "] ";
255 void MathInset::dump() const
257 lyxerr << "---------------------------------------------\n";
258 write(lyxerr, false);
259 lyxerr << "\n---------------------------------------------\n";
263 void MathInset::push_back(unsigned char, MathTextCodes)
265 lyxerr << "can't push without a cell\n";
269 void MathInset::push_back(MathInset *)
271 lyxerr << "can't push without a cell\n";
275 bool MathInset::covers(int x, int y) const
279 x <= xo_ + width() &&
280 y >= yo_ - ascent() &&
281 y <= yo_ + descent();
285 void MathInset::validate(LaTeXFeatures &) const
289 std::vector<int> MathInset::idxBetween(int from, int to) const
291 std::vector<int> res;
292 for (int i = from; i <= to; ++i)
298 MathTextCodes MathInset::code() const
304 void MathInset::code(MathTextCodes t)
310 void MathInset::metrics(MathStyles st) const
312 lyxerr[Debug::MATHED] << "MathInset::metrics() called directly!\n";
317 void MathInset::draw(Painter &, int, int) const
319 lyxerr << "MathInset::draw() called directly!\n";
323 void MathInset::write(std::ostream &, bool) const
325 lyxerr << "MathInset::write() called directly!\n";