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
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
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
|
|
|
|
///
|
2005-11-28 10:23:19 +00:00
|
|
|
|
mode_type currentMode() const { return MATH_MODE; }
|
|
|
|
|
///
|
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
|
|
|
|
|
2004-01-26 10:13:15 +00:00
|
|
|
|
/// move cursor left
|
|
|
|
|
bool idxLeft(LCursor & cur) const;
|
|
|
|
|
/// move cursor right
|
|
|
|
|
bool idxRight(LCursor & cur) const;
|
|
|
|
|
/// move cursor up or down
|
|
|
|
|
bool idxUpDown(LCursor & cur, bool up) const;
|
|
|
|
|
/// Target pos when we enter the inset from the left by pressing "Right"
|
|
|
|
|
bool idxFirst(LCursor & cur) const;
|
|
|
|
|
/// Target pos when we enter the inset from the right by pressing "Left"
|
|
|
|
|
bool idxLast(LCursor & cur) const;
|
|
|
|
|
|
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;
|
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_; }
|
2004-04-05 16:31:52 +00:00
|
|
|
|
/// returns subscript. Always run 'hasDown' or 'has(false)' before!
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray const & down() const;
|
2004-04-05 16:31:52 +00:00
|
|
|
|
/// returns subscript. Always run 'hasDown' or 'has(false)' before!
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray & down();
|
2004-04-05 16:31:52 +00:00
|
|
|
|
/// returns superscript. Always run 'hasUp' or 'has(true)' before!
|
2002-08-02 14:29:42 +00:00
|
|
|
|
MathArray const & up() const;
|
2004-04-05 16:31:52 +00:00
|
|
|
|
/// returns superscript. Always run 'hasUp' or 'has(true)' before!
|
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;
|
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
|
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;
|
2003-10-29 10:47:21 +00:00
|
|
|
|
protected:
|
2004-11-24 21:58:42 +00:00
|
|
|
|
virtual void doDispatch(LCursor & cur, FuncRequest & cmd);
|
2002-07-30 13:56:02 +00:00
|
|
|
|
private:
|
2004-11-23 23:04:52 +00:00
|
|
|
|
virtual std::auto_ptr<InsetBase> doClone() const;
|
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
|
2004-04-05 16:31:52 +00:00
|
|
|
|
void notifyCursorLeaves(LCursor & 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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|