2001-06-25 00:06:33 +00:00
|
|
|
|
// -*- C++ -*-
|
2003-08-19 13:00:56 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file math_scriptinset.h
|
|
|
|
|
* 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
|
|
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
|
#include "math_nestinset.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
|
|
|
|
|
2003-08-19 13:00:56 +00:00
|
|
|
|
/// An inset for super- and subscripts.
|
2001-08-03 17:10:22 +00:00
|
|
|
|
class MathScriptInset : public MathNestInset {
|
2001-06-25 00:06:33 +00:00
|
|
|
|
public:
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// create inset without scripts
|
2001-10-12 12:02:49 +00:00
|
|
|
|
MathScriptInset();
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// create inset with single script
|
2001-09-24 16:25:06 +00:00
|
|
|
|
explicit MathScriptInset(bool up);
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// create inset with single script and given nucleus
|
|
|
|
|
MathScriptInset(MathAtom const & at, bool up);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-07-25 17:11:25 +00:00
|
|
|
|
virtual std::auto_ptr<InsetBase> clone() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2003-06-02 10:03:27 +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
|
|
|
|
|
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
|
|
|
|
|
void mathmlize(MathMLStream &) const;
|
|
|
|
|
/// write content as something readable by Octave
|
2003-02-14 14:30:09 +00:00
|
|
|
|
void octave(OctaveStream &) const;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// move cursor left
|
2001-11-15 09:51:57 +00:00
|
|
|
|
bool idxLeft(idx_type &, pos_type &) const;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// move cursor right
|
2001-11-15 09:51:57 +00:00
|
|
|
|
bool idxRight(idx_type &, pos_type &) const;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// move cursor up or down
|
|
|
|
|
bool idxUpDown(idx_type & idx, pos_type & pos, bool up, int targetx) const;
|
|
|
|
|
/// Target pos when we enter the inset from the left by pressing "Right"
|
|
|
|
|
bool idxFirst(idx_type & idx, pos_type & pos) const;
|
|
|
|
|
/// Target pos when we enter the inset from the right by pressing "Left"
|
|
|
|
|
bool idxLast(idx_type & idx, pos_type & pos) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
|
/// can we enter this cell?
|
2002-11-06 11:09:19 +00:00
|
|
|
|
bool validCell(idx_type i) const { return i == 2 || script_[i]; }
|
2001-10-12 15:38:58 +00:00
|
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// identifies scriptinsets
|
2001-09-24 16:25:06 +00:00
|
|
|
|
MathScriptInset const * asScriptInset() const;
|
|
|
|
|
///
|
2001-10-12 12:02:49 +00:00
|
|
|
|
MathScriptInset * asScriptInset();
|
|
|
|
|
|
|
|
|
|
/// 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_; }
|
|
|
|
|
/// returns subscript
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray const & down() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns subscript
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray & down();
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// returns superscript
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray const & up() const;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// returns superscript
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray & up();
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// returns nucleus
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray const & nuc() const;
|
2002-07-30 13:56:02 +00:00
|
|
|
|
/// returns nucleus
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray & 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;
|
|
|
|
|
/// 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
|
2002-07-09 10:06:27 +00:00
|
|
|
|
void infoize(std::ostream & os) const;
|
2003-01-07 11:24:43 +00:00
|
|
|
|
/// say whether we have displayed limits
|
|
|
|
|
void infoize2(std::ostream & os) const;
|
2002-08-28 17:59:32 +00:00
|
|
|
|
/// local dispatcher
|
2003-02-18 11:47:16 +00:00
|
|
|
|
dispatch_result dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
|
private:
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns x offset for main part
|
2002-07-30 13:56:02 +00:00
|
|
|
|
int dxx() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns width of nucleus if any
|
2002-07-30 13:56:02 +00:00
|
|
|
|
int nwid() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns y offset for superscript
|
2002-07-30 13:56:02 +00:00
|
|
|
|
int dy0() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns y offset for subscript
|
2002-07-30 13:56:02 +00:00
|
|
|
|
int dy1() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns x offset for superscript
|
2002-07-30 13:56:02 +00:00
|
|
|
|
int dx0() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns x offset for subscript
|
2002-07-30 13:56:02 +00:00
|
|
|
|
int dx1() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns ascent of nucleus if any
|
2002-07-30 13:56:02 +00:00
|
|
|
|
int nasc() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns descent of nucleus if any
|
2002-07-30 13:56:02 +00:00
|
|
|
|
int ndes() 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;
|
2002-10-29 08:23:32 +00:00
|
|
|
|
/// clean up empty cells
|
|
|
|
|
void notifyCursorLeaves(idx_type idx);
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
|
|
|
|
/// possible subscript (index 0) and superscript (index 1)
|
2002-03-21 17:42:56 +00:00
|
|
|
|
bool script_[2];
|
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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|