1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-11 08:26:02 +00:00
|
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
|
* \file InsetMath.h
|
2003-08-19 13:00:56 +00:00
|
|
|
|
* 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
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "MathData.h"
|
2004-11-16 20:41:38 +00:00
|
|
|
|
|
2003-02-17 17:12:50 +00:00
|
|
|
|
#include "insets/insetbase.h"
|
2001-02-13 19:10:18 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-09-03 16:14:51 +00:00
|
|
|
|
enum HullType {
|
|
|
|
|
hullNone,
|
|
|
|
|
hullSimple,
|
|
|
|
|
hullEquation,
|
|
|
|
|
hullEqnArray,
|
|
|
|
|
hullAlign,
|
|
|
|
|
hullAlignAt,
|
|
|
|
|
hullXAlignAt,
|
|
|
|
|
hullXXAlignAt,
|
|
|
|
|
hullFlAlign,
|
|
|
|
|
hullMultline,
|
|
|
|
|
hullGather
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
HullType hullType(std::string const & name);
|
|
|
|
|
std::string hullName(HullType type);
|
|
|
|
|
|
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
|
2006-09-16 18:11:38 +00:00
|
|
|
|
(InsetMathNests, in fact) thus forming a tree. The root of this tree is
|
|
|
|
|
always a InsetMathHull, 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;
|
2006-09-16 18:11:38 +00:00
|
|
|
|
class InsetMathArray;
|
|
|
|
|
class InsetMathAMSArray;
|
|
|
|
|
class InsetMathBrace;
|
|
|
|
|
class InsetMathChar;
|
|
|
|
|
class InsetMathDelim;
|
|
|
|
|
class InsetMathFrac;
|
|
|
|
|
class InsetMathFont;
|
|
|
|
|
class InsetMathGrid;
|
|
|
|
|
class InsetMathHull;
|
|
|
|
|
class InsetMathMatrix;
|
|
|
|
|
class InsetMathNest;
|
|
|
|
|
class InsetMathParbox;
|
|
|
|
|
class InsetMathScript;
|
|
|
|
|
class InsetMathString;
|
|
|
|
|
class InsetMathSpace;
|
|
|
|
|
class InsetMathSymbol;
|
|
|
|
|
class InsetMathUnknown;
|
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
|
|
|
|
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
class InsetMath : public InsetBase {
|
2002-03-21 17:42:56 +00:00
|
|
|
|
public:
|
2004-01-15 11:58:35 +00:00
|
|
|
|
/// identification as math inset
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMath * asInsetMath() { 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
|
2006-09-16 18:11:38 +00:00
|
|
|
|
virtual InsetMathAMSArray * asAMSArrayInset() { return 0; }
|
|
|
|
|
virtual InsetMathAMSArray const * asAMSArrayInset() const { return 0; }
|
|
|
|
|
virtual InsetMathArray * asArrayInset() { return 0; }
|
|
|
|
|
virtual InsetMathArray const * asArrayInset() const { return 0; }
|
|
|
|
|
virtual InsetMathBrace const * asBraceInset() const { return 0; }
|
|
|
|
|
virtual InsetMathChar const * asCharInset() const { return 0; }
|
|
|
|
|
virtual InsetMathDelim * asDelimInset() { return 0; }
|
|
|
|
|
virtual InsetMathDelim const * asDelimInset() const { return 0; }
|
|
|
|
|
virtual InsetMathFrac * asFracInset() { return 0; }
|
|
|
|
|
virtual InsetMathFrac const * asFracInset() const { return 0; }
|
|
|
|
|
virtual InsetMathFont * asFontInset() { return 0; }
|
|
|
|
|
virtual InsetMathFont const * asFontInset() const { return 0; }
|
|
|
|
|
virtual InsetMathGrid * asGridInset() { return 0; }
|
|
|
|
|
virtual InsetMathGrid const * asGridInset() const { return 0; }
|
|
|
|
|
virtual InsetMathHull * asHullInset() { return 0; }
|
|
|
|
|
virtual InsetMathHull 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; }
|
2006-09-16 18:11:38 +00:00
|
|
|
|
virtual InsetMathMatrix const * asMatrixInset() const { return 0; }
|
|
|
|
|
virtual InsetMathNest * asNestInset() { return 0; }
|
|
|
|
|
virtual InsetMathNest const * asNestInset() const { return 0; }
|
|
|
|
|
virtual InsetMathParbox * asParboxInset() { return 0; }
|
|
|
|
|
virtual InsetMathScript * asScriptInset() { return 0; }
|
|
|
|
|
virtual InsetMathScript const * asScriptInset() const { return 0; }
|
|
|
|
|
virtual InsetMathSpace * asSpaceInset() { return 0; }
|
|
|
|
|
virtual InsetMathSpace const * asSpaceInset() const { return 0; }
|
|
|
|
|
virtual InsetMathString * asStringInset() { return 0; }
|
|
|
|
|
virtual InsetMathString const * asStringInset() const { return 0; }
|
|
|
|
|
virtual InsetMathSymbol const * asSymbolInset() const { return 0; }
|
|
|
|
|
virtual InsetMathUnknown * asUnknownInset() { return 0; }
|
|
|
|
|
virtual InsetMathUnknown 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
|
2006-09-03 16:14:51 +00:00
|
|
|
|
virtual HullType getType() const;
|
2002-07-08 06:39:40 +00:00
|
|
|
|
/// change type
|
2006-09-03 16:14:51 +00:00
|
|
|
|
virtual void mutate(HullType /*newtype*/) {}
|
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
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
///
|
2002-05-24 08:29:16 +00:00
|
|
|
|
std::ostream & operator<<(std::ostream &, MathAtom const &);
|
2006-10-19 16:51:30 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstream & operator<<(odocstream &, 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
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
|
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#endif
|