2001-06-25 00:06:33 +00:00
|
|
|
|
// -*- C++ -*-
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma interface
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/** Inset for super- and subscripts
|
2002-09-11 08:26:02 +00:00
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS
|
2001-06-25 00:06:33 +00:00
|
|
|
|
*/
|
|
|
|
|
|
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
|
|
|
|
///
|
2001-06-28 10:25:20 +00:00
|
|
|
|
MathInset * clone() const;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
///
|
2002-07-30 13:56:02 +00:00
|
|
|
|
void metrics(MathMetricsInfo & mi) const;
|
2001-07-26 06:46:50 +00:00
|
|
|
|
///
|
2002-07-30 13:56:02 +00:00
|
|
|
|
void draw(MathPainterInfo & pi, int x, int y) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
|
///
|
2002-07-30 13:56:02 +00:00
|
|
|
|
void metricsT(TextMetricsInfo const & mi) 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
|
|
|
|
|
void maplize(MapleStream &) const;
|
|
|
|
|
/// write content as something readable by Mathematica
|
|
|
|
|
void mathematicize(MathematicaStream &) const;
|
|
|
|
|
/// write content as something resembling MathML
|
|
|
|
|
void mathmlize(MathMLStream &) const;
|
|
|
|
|
/// write content as something readable by Octave
|
|
|
|
|
void octavize(OctaveStream &) const;
|
|
|
|
|
/// 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?
|
|
|
|
|
bool validCell(idx_type i) const { return 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);
|
2002-07-08 13:03:37 +00:00
|
|
|
|
///
|
2002-07-09 10:06:27 +00:00
|
|
|
|
void infoize(std::ostream & os) const;
|
2002-08-28 17:59:32 +00:00
|
|
|
|
/// local dispatcher
|
|
|
|
|
result_type 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
|