1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-11 08:26:02 +00:00
|
|
|
|
/**
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* \file math_inset.h
|
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* \author Alejandro Aguilar Sierra
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* Full author contact details are available in file CREDITS.
|
1999-09-27 18:44:28 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#ifndef MATH_INSET_H
|
|
|
|
|
#define MATH_INSET_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2004-11-16 20:41:38 +00:00
|
|
|
|
#include "math_data.h"
|
|
|
|
|
|
2003-02-17 17:12:50 +00:00
|
|
|
|
#include "insets/insetbase.h"
|
2001-02-13 19:10:18 +00:00
|
|
|
|
|
2003-10-06 15:43:21 +00:00
|
|
|
|
#include <string>
|
|
|
|
|
|
2001-12-03 16:24:50 +00:00
|
|
|
|
/**
|
|
|
|
|
|
|
|
|
|
Abstract base class for all math objects. A math insets is for use of the
|
|
|
|
|
math editor only, it isn't a general LyX inset. It's used to represent all
|
2002-03-21 17:42:56 +00:00
|
|
|
|
the math objects.
|
2001-12-03 16:24:50 +00:00
|
|
|
|
|
|
|
|
|
Math insets do not know there parents, a cursor position or things
|
|
|
|
|
like that. The are dumb object that are contained in other math insets
|
2003-06-02 10:03:27 +00:00
|
|
|
|
(MathNestInsets, in fact) thus forming a tree. The root of this tree is
|
|
|
|
|
always a MathHullInset, which provides an interface to the Outer World by
|
2001-12-03 16:24:50 +00:00
|
|
|
|
inclusion in the "real LyX insets" FormulaInset and FormulaMacroInset.
|
|
|
|
|
|
2001-02-15 12:22:01 +00:00
|
|
|
|
*/
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2003-11-05 12:06:20 +00:00
|
|
|
|
class OutputParams;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
class MathArrayInset;
|
2002-04-24 17:07:42 +00:00
|
|
|
|
class MathAMSArrayInset;
|
2004-04-13 06:27:29 +00:00
|
|
|
|
class MathBraceInset;
|
2001-08-17 13:18:10 +00:00
|
|
|
|
class MathCharInset;
|
2001-11-09 08:35:57 +00:00
|
|
|
|
class MathDelimInset;
|
2001-11-13 18:33:48 +00:00
|
|
|
|
class MathFracInset;
|
2002-10-29 08:23:32 +00:00
|
|
|
|
class MathFontInset;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
class MathGridInset;
|
2001-11-08 12:28:33 +00:00
|
|
|
|
class MathHullInset;
|
2001-11-09 08:35:57 +00:00
|
|
|
|
class MathMatrixInset;
|
|
|
|
|
class MathNestInset;
|
2002-07-08 11:29:51 +00:00
|
|
|
|
class MathParboxInset;
|
2001-10-19 11:25:48 +00:00
|
|
|
|
class MathScriptInset;
|
2001-11-09 12:01:10 +00:00
|
|
|
|
class MathStringInset;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
class MathSpaceInset;
|
2001-11-09 14:23:44 +00:00
|
|
|
|
class MathSymbolInset;
|
2002-02-01 17:01:30 +00:00
|
|
|
|
class MathUnknownInset;
|
2002-07-08 06:39:40 +00:00
|
|
|
|
|
2003-02-25 18:21:48 +00:00
|
|
|
|
class RefInset;
|
2001-07-13 14:54:56 +00:00
|
|
|
|
|
2001-11-09 08:35:57 +00:00
|
|
|
|
class NormalStream;
|
|
|
|
|
class OctaveStream;
|
|
|
|
|
class MapleStream;
|
2002-10-28 17:15:19 +00:00
|
|
|
|
class MaximaStream;
|
2002-07-01 11:17:14 +00:00
|
|
|
|
class MathematicaStream;
|
2001-11-09 08:35:57 +00:00
|
|
|
|
class MathMLStream;
|
|
|
|
|
class WriteStream;
|
2002-01-16 14:24:38 +00:00
|
|
|
|
class InfoStream;
|
2001-11-09 08:35:57 +00:00
|
|
|
|
|
2001-11-09 14:23:44 +00:00
|
|
|
|
class MathMacroTemplate;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
class MathMacro;
|
2001-12-05 17:50:18 +00:00
|
|
|
|
class MathPosFinder;
|
2002-07-11 11:27:24 +00:00
|
|
|
|
class Dimension;
|
2004-01-20 14:25:24 +00:00
|
|
|
|
class LCursor;
|
2003-06-02 10:03:27 +00:00
|
|
|
|
class TextPainter;
|
|
|
|
|
class TextMetricsInfo;
|
|
|
|
|
class ReplaceData;
|
2001-10-19 11:25:48 +00:00
|
|
|
|
|
|
|
|
|
|
2003-02-17 17:12:50 +00:00
|
|
|
|
class MathInset : public InsetBase {
|
2002-03-21 17:42:56 +00:00
|
|
|
|
public:
|
2004-01-15 11:58:35 +00:00
|
|
|
|
/// identification as math inset
|
|
|
|
|
MathInset * asMathInset() { return this; }
|
2004-02-25 14:39:14 +00:00
|
|
|
|
/// this is overridden in math text insets (i.e. mbox)
|
|
|
|
|
bool inMathed() const { return true; }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2002-03-18 11:45:53 +00:00
|
|
|
|
/// the ascent of the inset above the baseline
|
|
|
|
|
/// compute the size of the object for text based drawing
|
2003-05-28 13:22:36 +00:00
|
|
|
|
virtual void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
|
/// draw the object as text
|
2002-03-21 06:57:13 +00:00
|
|
|
|
virtual void drawT(TextPainter &, int x, int y) const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2001-11-22 09:48:57 +00:00
|
|
|
|
/// return cell given its number
|
2001-09-26 16:52:34 +00:00
|
|
|
|
virtual MathArray & cell(idx_type);
|
2001-11-22 09:48:57 +00:00
|
|
|
|
/// return cell given its number
|
2001-09-26 16:52:34 +00:00
|
|
|
|
virtual MathArray const & cell(idx_type) const;
|
2002-03-21 17:42:56 +00:00
|
|
|
|
|
2001-11-09 12:01:10 +00:00
|
|
|
|
/// identifies certain types of insets
|
2002-08-09 10:22:35 +00:00
|
|
|
|
virtual MathAMSArrayInset * asAMSArrayInset() { return 0; }
|
|
|
|
|
virtual MathAMSArrayInset const * asAMSArrayInset() const { return 0; }
|
|
|
|
|
virtual MathArrayInset * asArrayInset() { return 0; }
|
|
|
|
|
virtual MathArrayInset const * asArrayInset() const { return 0; }
|
2004-04-13 06:27:29 +00:00
|
|
|
|
virtual MathBraceInset const * asBraceInset() const { return 0; }
|
2002-08-09 10:22:35 +00:00
|
|
|
|
virtual MathCharInset const * asCharInset() const { return 0; }
|
|
|
|
|
virtual MathDelimInset * asDelimInset() { return 0; }
|
|
|
|
|
virtual MathDelimInset const * asDelimInset() const { return 0; }
|
|
|
|
|
virtual MathFracInset * asFracInset() { return 0; }
|
|
|
|
|
virtual MathFracInset const * asFracInset() const { return 0; }
|
2002-10-29 08:23:32 +00:00
|
|
|
|
virtual MathFontInset * asFontInset() { return 0; }
|
|
|
|
|
virtual MathFontInset const * asFontInset() const { return 0; }
|
2002-08-09 10:22:35 +00:00
|
|
|
|
virtual MathGridInset * asGridInset() { return 0; }
|
|
|
|
|
virtual MathGridInset const * asGridInset() const { return 0; }
|
|
|
|
|
virtual MathHullInset * asHullInset() { return 0; }
|
|
|
|
|
virtual MathHullInset const * asHullInset() const { return 0; }
|
2004-04-13 06:27:29 +00:00
|
|
|
|
virtual MathMacro * asMacro() { return 0; }
|
|
|
|
|
virtual MathMacro const * asMacro() const { return 0; }
|
2002-08-09 10:22:35 +00:00
|
|
|
|
virtual MathMacroTemplate * asMacroTemplate() { return 0; }
|
|
|
|
|
virtual MathMacroTemplate const * asMacroTemplate() const { return 0; }
|
|
|
|
|
virtual MathMatrixInset const * asMatrixInset() const { return 0; }
|
|
|
|
|
virtual MathNestInset * asNestInset() { return 0; }
|
|
|
|
|
virtual MathNestInset const * asNestInset() const { return 0; }
|
|
|
|
|
virtual MathParboxInset * asParboxInset() { return 0; }
|
|
|
|
|
virtual MathScriptInset * asScriptInset() { return 0; }
|
|
|
|
|
virtual MathScriptInset const * asScriptInset() const { return 0; }
|
|
|
|
|
virtual MathSpaceInset * asSpaceInset() { return 0; }
|
|
|
|
|
virtual MathSpaceInset const * asSpaceInset() const { return 0; }
|
|
|
|
|
virtual MathStringInset * asStringInset() { return 0; }
|
|
|
|
|
virtual MathStringInset const * asStringInset() const { return 0; }
|
|
|
|
|
virtual MathSymbolInset const * asSymbolInset() const { return 0; }
|
|
|
|
|
virtual MathUnknownInset * asUnknownInset() { return 0; }
|
|
|
|
|
virtual MathUnknownInset const * asUnknownInset() const { return 0; }
|
2003-02-25 18:21:48 +00:00
|
|
|
|
virtual RefInset * asRefInset() { return 0; }
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
|
|
|
|
/// identifies things that can get scripts
|
|
|
|
|
virtual bool isScriptable() const { return false; }
|
2001-11-22 09:48:57 +00:00
|
|
|
|
/// is the a relational operator (used for splitting equations)
|
2001-08-09 08:53:16 +00:00
|
|
|
|
virtual bool isRelOp() const { return false; }
|
2002-07-10 07:15:36 +00:00
|
|
|
|
/// will this get written as a single block in {..}
|
|
|
|
|
virtual bool extraBraces() const { return false; }
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
2001-11-22 09:48:57 +00:00
|
|
|
|
/// return the content as char if the inset is able to do so
|
2001-08-03 17:10:22 +00:00
|
|
|
|
virtual char getChar() const { return 0; }
|
2001-09-11 10:58:17 +00:00
|
|
|
|
/// identifies things that can get \limits or \nolimits
|
|
|
|
|
virtual bool takesLimits() const { return false; }
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2001-11-22 09:48:57 +00:00
|
|
|
|
/// char char code if possible
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual void handleFont(std::string const &) {}
|
2001-11-22 09:48:57 +00:00
|
|
|
|
/// replace things by other things
|
2001-11-16 09:55:37 +00:00
|
|
|
|
virtual void replace(ReplaceData &) {}
|
2002-02-01 17:01:30 +00:00
|
|
|
|
/// do we contain a given subsequence?
|
2002-08-08 16:08:11 +00:00
|
|
|
|
virtual bool contains(MathArray const &) const { return false; }
|
2002-05-30 07:09:54 +00:00
|
|
|
|
/// access to the lock (only nest array have one)
|
|
|
|
|
virtual bool lock() const { return false; }
|
|
|
|
|
/// access to the lock (only nest array have one)
|
|
|
|
|
virtual void lock(bool) {}
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
2002-01-11 15:23:10 +00:00
|
|
|
|
/// write LaTeX and Lyx code
|
|
|
|
|
virtual void write(WriteStream & os) const;
|
2001-11-08 12:06:56 +00:00
|
|
|
|
/// write normalized content
|
2001-11-09 08:35:57 +00:00
|
|
|
|
virtual void normalize(NormalStream &) const;
|
2001-11-22 09:48:57 +00:00
|
|
|
|
/// write content as something readable by Maple
|
2003-02-14 14:30:09 +00:00
|
|
|
|
virtual void maple(MapleStream &) const;
|
2002-10-28 17:15:19 +00:00
|
|
|
|
/// write content as something readable by Maxima
|
2003-02-14 14:30:09 +00:00
|
|
|
|
virtual void maxima(MaximaStream &) const;
|
2002-07-01 11:17:14 +00:00
|
|
|
|
/// write content as something readable by Mathematica
|
2003-02-14 14:30:09 +00:00
|
|
|
|
virtual void mathematica(MathematicaStream &) const;
|
2001-11-22 09:48:57 +00:00
|
|
|
|
/// write content as something resembling MathML
|
2001-11-07 17:30:26 +00:00
|
|
|
|
virtual void mathmlize(MathMLStream &) const;
|
2001-11-22 09:48:57 +00:00
|
|
|
|
/// write content as something readable by Octave
|
2003-02-14 14:30:09 +00:00
|
|
|
|
virtual void octave(OctaveStream &) const;
|
2001-11-22 09:48:57 +00:00
|
|
|
|
|
|
|
|
|
/// dump content to stderr for debugging
|
|
|
|
|
virtual void dump() const;
|
2002-07-08 06:39:40 +00:00
|
|
|
|
|
|
|
|
|
/// LyXInset stuff
|
|
|
|
|
virtual bool numberedType() const { return false; }
|
|
|
|
|
/// hull type
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string const & getType() const;
|
2002-07-08 06:39:40 +00:00
|
|
|
|
/// change type
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual void mutate(std::string const &) {}
|
2002-08-01 15:53:46 +00:00
|
|
|
|
/// usually the latex name
|
2003-10-06 15:43:21 +00:00
|
|
|
|
virtual std::string name() const;
|
2004-10-05 10:11:42 +00:00
|
|
|
|
|
2004-08-14 19:55:00 +00:00
|
|
|
|
/// math stuff usually isn't allowed in text mode
|
|
|
|
|
virtual bool allowedIn(mode_type mode) const { return mode == MATH_MODE; }
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2002-05-24 08:29:16 +00:00
|
|
|
|
std::ostream & operator<<(std::ostream &, MathAtom const &);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2002-10-22 13:56:40 +00:00
|
|
|
|
// initialize math
|
2002-07-12 14:24:47 +00:00
|
|
|
|
void initMath();
|
2002-06-24 15:37:14 +00:00
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#endif
|