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
|
|
|
|
|
\author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
*/
|
|
|
|
|
|
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);
|
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
|
|
|
|
///
|
2001-11-09 08:35:57 +00:00
|
|
|
|
void write(WriteStream & os) const;
|
2001-07-26 06:46:50 +00:00
|
|
|
|
///
|
2001-11-09 08:35:57 +00:00
|
|
|
|
void normalize(NormalStream & os) const;
|
2001-10-24 16:10:38 +00:00
|
|
|
|
///
|
2001-10-19 11:25:48 +00:00
|
|
|
|
void metrics(MathMetricsInfo const & st) const;
|
2001-07-26 06:46:50 +00:00
|
|
|
|
///
|
2001-08-06 17:20:26 +00:00
|
|
|
|
void draw(Painter &, int x, int y) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
|
///
|
2002-03-21 06:57:13 +00:00
|
|
|
|
void metricsT(TextMetricsInfo const & st) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
|
///
|
2002-03-21 06:57:13 +00:00
|
|
|
|
void drawT(TextPainter &, int x, int y) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
|
|
|
|
///
|
2001-11-08 12:06:56 +00:00
|
|
|
|
void metrics(MathInset const * nuc, MathMetricsInfo const & st) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
///
|
2001-11-08 12:06:56 +00:00
|
|
|
|
void draw(MathInset const * nuc, Painter &, int x, int y) const;
|
2001-10-24 16:10:38 +00:00
|
|
|
|
///
|
2002-03-21 06:57:13 +00:00
|
|
|
|
void metricsT(MathInset const * nuc, TextMetricsInfo const & st) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
|
///
|
2002-03-21 06:57:13 +00:00
|
|
|
|
void drawT(MathInset const * nuc, TextPainter &, int x, int y) const;
|
2002-03-18 11:45:53 +00:00
|
|
|
|
///
|
2002-01-08 11:03:34 +00:00
|
|
|
|
int ascent2(MathInset const * nuc) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
///
|
2002-01-08 11:03:34 +00:00
|
|
|
|
int descent2(MathInset const * nuc) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
///
|
2002-01-08 11:03:34 +00:00
|
|
|
|
int width2(MathInset const * nuc) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
2001-10-12 15:38:58 +00:00
|
|
|
|
///
|
2001-11-15 09:51:57 +00:00
|
|
|
|
bool idxLeft(idx_type &, pos_type &) const;
|
2001-10-12 15:38:58 +00:00
|
|
|
|
///
|
2001-11-15 09:51:57 +00:00
|
|
|
|
bool idxRight(idx_type &, pos_type &) 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_; }
|
|
|
|
|
/// true if we have an "inner" position
|
|
|
|
|
MathXArray const & up() const;
|
|
|
|
|
/// returns subscript
|
|
|
|
|
MathXArray const & down() const;
|
|
|
|
|
/// returns superscript
|
|
|
|
|
MathXArray & up();
|
|
|
|
|
/// returns subscript
|
|
|
|
|
MathXArray & down();
|
|
|
|
|
/// 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;
|
2002-02-01 11:57:26 +00:00
|
|
|
|
/// do we have a anything?
|
|
|
|
|
bool empty() const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// remove script
|
|
|
|
|
void removeScript(bool up);
|
|
|
|
|
/// remove script
|
|
|
|
|
void removeEmptyScripts();
|
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);
|
|
|
|
|
|
2001-11-20 16:05:17 +00:00
|
|
|
|
// call these methods ...2 to make compaq cxx in anal mode happy...
|
2001-11-13 14:45:08 +00:00
|
|
|
|
/// suppresses empty braces if necessary
|
2001-11-20 16:05:17 +00:00
|
|
|
|
virtual void write2(MathInset const * nuc, WriteStream & os) const;
|
|
|
|
|
virtual void normalize2(MathInset const * nuc, NormalStream & os) const;
|
|
|
|
|
virtual void octavize2(MathInset const * nuc, OctaveStream & os) const;
|
|
|
|
|
virtual void maplize2(MathInset const * nuc, MapleStream & os) const;
|
|
|
|
|
virtual void mathmlize2(MathInset const * nuc, MathMLStream & os) const;
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
2001-10-12 12:02:49 +00:00
|
|
|
|
public:
|
|
|
|
|
/// returns x offset for main part
|
|
|
|
|
int dxx(MathInset const * nuc) const;
|
|
|
|
|
/// returns width of nucleus if any
|
|
|
|
|
int nwid(MathInset const * nuc) const;
|
2001-07-26 06:46:50 +00:00
|
|
|
|
private:
|
2001-10-12 12:02:49 +00:00
|
|
|
|
/// returns y offset for superscript
|
|
|
|
|
int dy0(MathInset const * nuc) const;
|
|
|
|
|
/// returns y offset for subscript
|
|
|
|
|
int dy1(MathInset const * nuc) const;
|
|
|
|
|
/// returns x offset for superscript
|
|
|
|
|
int dx0(MathInset const * nuc) const;
|
|
|
|
|
/// returns x offset for subscript
|
|
|
|
|
int dx1(MathInset const * nuc) const;
|
|
|
|
|
/// returns ascent of nucleus if any
|
|
|
|
|
int nasc(MathInset const * nuc) const;
|
|
|
|
|
/// returns descent of nucleus if any
|
|
|
|
|
int ndes(MathInset const * nuc) const;
|
2001-11-26 13:35:08 +00:00
|
|
|
|
/// where do we have to draw the scripts?
|
|
|
|
|
bool hasLimits(MathInset const * nuc) const;
|
2001-10-12 12:02:49 +00:00
|
|
|
|
|
|
|
|
|
/// possible subscript (index 0) and superscript (index 1)
|
|
|
|
|
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_;
|
2002-03-19 16:55:58 +00:00
|
|
|
|
/// cached font
|
|
|
|
|
mutable LyXFont font_;
|
2001-06-25 00:06:33 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|
2001-09-11 10:58:17 +00:00
|
|
|
|
|