1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-11 08:26:02 +00:00
|
|
|
|
/**
|
2007-04-25 16:11:45 +00:00
|
|
|
|
* \file MathMacro.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
|
|
|
|
*/
|
2003-08-19 13:00:56 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#ifndef MATH_MACRO_H
|
|
|
|
|
#define MATH_MACRO_H
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathNest.h"
|
2007-04-26 16:05:57 +00:00
|
|
|
|
#include "MathData.h"
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathNest.h"
|
2007-04-28 20:44:46 +00:00
|
|
|
|
#include "MacroTable.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
|
2003-08-19 13:00:56 +00:00
|
|
|
|
/// This class contains the data for a macro.
|
2006-09-16 18:11:38 +00:00
|
|
|
|
class MathMacro : public InsetMathNest {
|
2000-03-07 01:14:37 +00:00
|
|
|
|
public:
|
2001-04-24 16:13:38 +00:00
|
|
|
|
/// A macro can be built from an existing template
|
2007-04-17 16:49:17 +00:00
|
|
|
|
MathMacro(docstring const & name, int numargs);
|
2001-02-13 17:08:51 +00:00
|
|
|
|
///
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2001-02-13 17:08:51 +00:00
|
|
|
|
///
|
2004-04-13 06:27:29 +00:00
|
|
|
|
void drawExpanded(PainterInfo & pi, int x, int y) const;
|
2005-10-05 21:19:32 +00:00
|
|
|
|
/// draw selection background
|
|
|
|
|
void drawSelection(PainterInfo & pi, int x, int y) const;
|
2007-01-20 00:55:24 +00:00
|
|
|
|
/// draw decorations.
|
|
|
|
|
void drawDecoration(PainterInfo & pi, int x, int y) const
|
|
|
|
|
{ drawMarkers2(pi, x, y); }
|
2001-02-13 17:08:51 +00:00
|
|
|
|
///
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool metrics(MetricsInfo & mi, Dimension & dim) const;
|
2005-10-05 21:19:32 +00:00
|
|
|
|
/// get cursor position
|
2006-10-17 16:23:27 +00:00
|
|
|
|
void cursorPos(BufferView const & bv, CursorSlice const & sl,
|
|
|
|
|
bool boundary, int & x, int & y) const;
|
2005-10-05 21:19:32 +00:00
|
|
|
|
///
|
2007-04-29 13:39:47 +00:00
|
|
|
|
Inset * editXY(Cursor & cur, int x, int y);
|
2007-04-16 14:42:53 +00:00
|
|
|
|
/// target pos when we enter the inset from the left by pressing "Right"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool idxFirst(Cursor &) const;
|
2007-04-16 14:42:53 +00:00
|
|
|
|
/// target pos when we enter the inset from the right by pressing "Left"
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool idxLast(Cursor &) const;
|
2007-04-16 14:42:53 +00:00
|
|
|
|
///
|
2007-04-26 14:56:30 +00:00
|
|
|
|
virtual bool notifyCursorLeaves(Cursor &);
|
2001-02-13 17:08:51 +00:00
|
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
|
docstring name() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2007-04-26 16:05:57 +00:00
|
|
|
|
void setExpansion(MathData const & exp, MathData const & args) const;
|
2007-04-17 16:49:17 +00:00
|
|
|
|
|
2001-07-13 14:54:56 +00:00
|
|
|
|
///
|
2001-07-26 06:56:43 +00:00
|
|
|
|
void validate(LaTeXFeatures &) const;
|
2001-07-13 14:54:56 +00:00
|
|
|
|
|
2001-11-16 08:26:41 +00:00
|
|
|
|
///
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void maple(MapleStream &) const;
|
2001-11-16 08:26:41 +00:00
|
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void mathmlize(MathStream &) const;
|
2001-11-16 08:29:11 +00:00
|
|
|
|
///
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void octave(OctaveStream &) const;
|
2003-01-07 11:24:43 +00:00
|
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void infoize(odocstream &) const;
|
2003-01-07 11:24:43 +00:00
|
|
|
|
///
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void infoize2(odocstream &) const;
|
2001-11-16 08:26:41 +00:00
|
|
|
|
|
2001-04-24 16:13:38 +00:00
|
|
|
|
private:
|
2007-04-29 13:39:47 +00:00
|
|
|
|
virtual std::auto_ptr<Inset> doClone() const;
|
2007-04-17 16:49:17 +00:00
|
|
|
|
///
|
|
|
|
|
void updateExpansion() const;
|
|
|
|
|
|
2004-04-13 13:54:58 +00:00
|
|
|
|
/// name of macro
|
2006-10-22 10:15:23 +00:00
|
|
|
|
docstring name_;
|
2007-04-17 16:49:17 +00:00
|
|
|
|
/// the unexpanded macro defintition
|
2007-04-26 16:05:57 +00:00
|
|
|
|
mutable MathData tmpl_;
|
2005-10-05 21:19:32 +00:00
|
|
|
|
/// the macro substituted with our args
|
2007-04-26 16:05:57 +00:00
|
|
|
|
mutable MathData expanded_;
|
2007-05-24 16:29:40 +00:00
|
|
|
|
///
|
|
|
|
|
mutable MacroData macroBackup_;
|
|
|
|
|
///
|
|
|
|
|
mutable bool editing_;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
2001-04-24 16:13:38 +00:00
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
1999-09-27 18:44:28 +00:00
|
|
|
|
#endif
|