2001-06-25 00:06:33 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
2006-09-17 09:14:18 +00:00
|
|
|
|
* \file InsetMathScript.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.
|
|
|
|
|
*
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
|
*/
|
|
|
|
|
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#ifndef MATH_SCRIPTINSET_H
|
|
|
|
|
#define MATH_SCRIPTINSET_H
|
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "InsetMathNest.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
namespace lyx {
|
|
|
|
|
|
|
|
|
|
|
2004-03-25 09:16:36 +00:00
|
|
|
|
// An inset for super- and subscripts or both. The 'nucleus' is always
|
|
|
|
|
// cell 0. If there is just one script, it's cell 1 and cell_1_is_up_
|
|
|
|
|
// is set accordingly. If both are used, cell 1 is up and cell 2 is down.
|
|
|
|
|
|
2006-09-16 18:11:38 +00:00
|
|
|
|
class InsetMathScript : public InsetMathNest {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
public:
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// create inset without scripts
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathScript();
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// create inset with single script
|
2006-09-16 18:11:38 +00:00
|
|
|
|
explicit InsetMathScript(bool up);
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// create inset with single script and given nucleus
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathScript(MathAtom const & at, bool up);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2005-11-28 10:23:19 +00:00
|
|
|
|
mode_type currentMode() const { return MATH_MODE; }
|
|
|
|
|
///
|
2007-09-21 20:39:47 +00:00
|
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
2001-07-26 06:46:50 +00:00
|
|
|
|
///
|
2003-03-21 14:20:48 +00:00
|
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
|
///
|
2003-05-28 13:22:36 +00:00
|
|
|
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
|
///
|
2002-07-30 13:56:02 +00:00
|
|
|
|
void drawT(TextPainter & pi, int x, int y) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
2007-11-05 19:44:03 +00:00
|
|
|
|
/// move cursor backwards
|
|
|
|
|
bool idxBackward(Cursor & cur) const;
|
|
|
|
|
/// move cursor forward
|
|
|
|
|
bool idxForward(Cursor & cur) const;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
/// move cursor up or down
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool idxUpDown(Cursor & cur, bool up) const;
|
2007-11-05 19:41:16 +00:00
|
|
|
|
/// Target pos when we enter the inset while moving forward
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool idxFirst(Cursor & cur) const;
|
2007-11-05 19:41:16 +00:00
|
|
|
|
/// Target pos when we enter the inset while moving backwards
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool idxLast(Cursor & cur) const;
|
2004-01-26 10:13:15 +00:00
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// write LaTeX and Lyx code
|
|
|
|
|
void write(WriteStream & os) const;
|
|
|
|
|
/// write normalized content
|
|
|
|
|
void normalize(NormalStream &) const;
|
|
|
|
|
/// write content as something readable by Maple
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void maple(MapleStream &) const;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// write content as something readable by Mathematica
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void mathematica(MathematicaStream &) const;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// write content as something resembling MathML
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void mathmlize(MathStream &) const;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// write content as something readable by Octave
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void octave(OctaveStream &) const;
|
2001-10-12 15:38:58 +00:00
|
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// identifies scriptinsets
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathScript const * asScriptInset() const;
|
2001-09-24 16:25:06 +00:00
|
|
|
|
///
|
2006-09-16 18:11:38 +00:00
|
|
|
|
InsetMathScript * asScriptInset();
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
|
|
|
|
/// set limits
|
|
|
|
|
void limits(int lim) { limits_ = lim; }
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// get limits
|
2001-10-12 12:02:49 +00:00
|
|
|
|
int limits() const { return limits_; }
|
2004-04-05 16:31:52 +00:00
|
|
|
|
/// returns subscript. Always run 'hasDown' or 'has(false)' before!
|
2007-04-26 16:05:57 +00:00
|
|
|
|
MathData const & down() const;
|
2004-04-05 16:31:52 +00:00
|
|
|
|
/// returns subscript. Always run 'hasDown' or 'has(false)' before!
|
2007-04-26 16:05:57 +00:00
|
|
|
|
MathData & down();
|
2004-04-05 16:31:52 +00:00
|
|
|
|
/// returns superscript. Always run 'hasUp' or 'has(true)' before!
|
2007-04-26 16:05:57 +00:00
|
|
|
|
MathData const & up() const;
|
2004-04-05 16:31:52 +00:00
|
|
|
|
/// returns superscript. Always run 'hasUp' or 'has(true)' before!
|
2007-04-26 16:05:57 +00:00
|
|
|
|
MathData & up();
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// returns nucleus
|
2007-04-26 16:05:57 +00:00
|
|
|
|
MathData const & nuc() const;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// returns nucleus
|
2007-04-26 16:05:57 +00:00
|
|
|
|
MathData & nuc();
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// do we have a superscript?
|
|
|
|
|
bool hasUp() const;
|
|
|
|
|
/// do we have a subscript?
|
|
|
|
|
bool hasDown() const;
|
|
|
|
|
/// do we have a script?
|
|
|
|
|
bool has(bool up) const;
|
2004-03-25 09:16:36 +00:00
|
|
|
|
/// what idx has super/subscript?
|
|
|
|
|
idx_type idxOfScript(bool up) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// remove script
|
|
|
|
|
void removeScript(bool up);
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// make sure a script is accessible
|
2001-10-12 12:02:49 +00:00
|
|
|
|
void ensure(bool up);
|
2003-01-07 11:24:43 +00:00
|
|
|
|
/// say that we have scripts
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void infoize(odocstream & os) const;
|
2003-01-07 11:24:43 +00:00
|
|
|
|
/// say whether we have displayed limits
|
2006-10-22 10:15:23 +00:00
|
|
|
|
void infoize2(odocstream & os) const;
|
2003-10-29 10:47:21 +00:00
|
|
|
|
protected:
|
2007-04-26 14:56:30 +00:00
|
|
|
|
virtual void doDispatch(Cursor & cur, FuncRequest & cmd);
|
2002-07-30 13:56:02 +00:00
|
|
|
|
private:
|
2007-08-30 18:03:17 +00:00
|
|
|
|
virtual Inset * clone() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns x offset for main part
|
2007-09-23 22:39:49 +00:00
|
|
|
|
int dxx(BufferView const & bv) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns width of nucleus if any
|
2007-09-24 13:52:04 +00:00
|
|
|
|
int nwid(BufferView const &) const;
|
2007-03-18 15:00:57 +00:00
|
|
|
|
/// returns y offset for either superscript or subscript
|
2007-09-24 13:52:04 +00:00
|
|
|
|
int dy01(BufferView const &, int asc, int des, int what) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns y offset for superscript
|
2007-09-24 13:52:04 +00:00
|
|
|
|
int dy0(BufferView const &) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns y offset for subscript
|
2007-09-24 13:52:04 +00:00
|
|
|
|
int dy1(BufferView const &) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns x offset for superscript
|
2007-09-23 22:39:49 +00:00
|
|
|
|
int dx0(BufferView const & bv) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns x offset for subscript
|
2007-09-23 22:39:49 +00:00
|
|
|
|
int dx1(BufferView const & bv) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns ascent of nucleus if any
|
2007-09-24 13:52:04 +00:00
|
|
|
|
int nasc(BufferView const &) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns descent of nucleus if any
|
2007-09-24 13:52:04 +00:00
|
|
|
|
int ndes(BufferView const &) const;
|
2007-03-21 17:21:59 +00:00
|
|
|
|
/// returns superscript kerning of nucleus if any
|
|
|
|
|
int nker() const;
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// where do we have to draw the scripts?
|
2002-07-30 13:56:02 +00:00
|
|
|
|
bool hasLimits() const;
|
2006-08-17 21:32:04 +00:00
|
|
|
|
/// clean up empty cells and return true if a cell has been deleted.
|
2007-04-26 14:56:30 +00:00
|
|
|
|
bool notifyCursorLeaves(Cursor & cur);
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
|
|
|
|
/// possible subscript (index 0) and superscript (index 1)
|
2004-03-25 09:16:36 +00:00
|
|
|
|
bool cell_1_is_up_;
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// 1 - "limits", -1 - "nolimits", 0 - "default"
|
2001-10-12 12:02:49 +00:00
|
|
|
|
int limits_;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
2001-06-25 00:06:33 +00:00
|
|
|
|
#endif
|