2001-08-03 17:10:22 +00:00
|
|
|
#ifndef MATH_NESTINSET_H
|
|
|
|
#define MATH_NESTINSET_H
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
#pragma interface
|
|
|
|
#endif
|
|
|
|
|
2001-08-03 17:55:10 +00:00
|
|
|
#include "math_diminset.h"
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/** Abstract base class for all math objects that contain nested items.
|
|
|
|
This is basically everything that is not a single character or a
|
2002-06-14 10:48:27 +00:00
|
|
|
single symbol.
|
2001-08-03 17:10:22 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
class LaTeXFeatures;
|
|
|
|
|
2001-08-03 17:55:10 +00:00
|
|
|
class MathNestInset : public MathDimInset {
|
2002-03-21 17:42:56 +00:00
|
|
|
public:
|
2001-11-26 13:35:08 +00:00
|
|
|
/// nestinsets have a fixed size to start with
|
2001-09-26 16:52:34 +00:00
|
|
|
explicit MathNestInset(idx_type ncells);
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/// the size is usuall some sort of convex hull of the cells
|
2002-06-14 10:48:27 +00:00
|
|
|
void metrics(MathMetricsInfo const & mi) const;
|
2002-07-11 10:20:31 +00:00
|
|
|
/// add space for markers
|
2002-07-11 11:27:24 +00:00
|
|
|
void metricsMarkers(int frame = 1) const;
|
2002-07-11 10:20:31 +00:00
|
|
|
/// add space for markers
|
2002-07-11 11:27:24 +00:00
|
|
|
void metricsMarkers2(int frame = 1) const;
|
2002-06-14 10:48:27 +00:00
|
|
|
/// draw background if locked
|
|
|
|
void draw(MathPainterInfo & pi, int x, int y) const;
|
2002-07-26 17:23:44 +00:00
|
|
|
/// draw selection background
|
|
|
|
void drawSelection(MathPainterInfo & pi,
|
|
|
|
idx_type idx1, pos_type pos1, idx_type idx2, pos_type pos2) const;
|
2002-06-24 15:37:14 +00:00
|
|
|
void drawMarkers(MathPainterInfo & pi, int x, int y) const;
|
2002-07-09 09:46:31 +00:00
|
|
|
/// draw four angular markers
|
|
|
|
void drawMarkers2(MathPainterInfo & pi, int x, int y) const;
|
2001-08-03 17:10:22 +00:00
|
|
|
/// appends itself with macro arguments substituted
|
2002-03-21 17:42:56 +00:00
|
|
|
void substitute(MathMacro const & macro);
|
2001-10-12 12:02:49 +00:00
|
|
|
/// identifies NestInsets
|
|
|
|
MathNestInset * asNestInset() { return this; }
|
2002-08-08 16:08:11 +00:00
|
|
|
/// identifies NestInsets
|
|
|
|
MathNestInset const * asNestInset() const { return this; }
|
2002-07-16 18:22:45 +00:00
|
|
|
/// get cursor position
|
|
|
|
void getPos(idx_type idx, pos_type pos, int & x, int & y) const;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/// order of movement through the cells when pressing the left key
|
2001-09-26 16:52:34 +00:00
|
|
|
bool idxLeft(idx_type & idx, pos_type & pos) const;
|
2001-11-26 13:35:08 +00:00
|
|
|
/// order of movement through the cells when pressing the right key
|
2001-09-26 16:52:34 +00:00
|
|
|
bool idxRight(idx_type & idx, pos_type & pos) const;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/// move one physical cell up
|
2001-09-26 16:52:34 +00:00
|
|
|
bool idxNext(idx_type & idx, pos_type & pos) const;
|
2001-11-26 13:35:08 +00:00
|
|
|
/// move one physical cell down
|
2001-09-26 16:52:34 +00:00
|
|
|
bool idxPrev(idx_type & idx, pos_type & pos) const;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/// target pos when we enter the inset from the left by pressing "Right"
|
2001-09-26 16:52:34 +00:00
|
|
|
bool idxFirst(idx_type & idx, pos_type & pos) const;
|
2001-11-26 13:35:08 +00:00
|
|
|
/// target pos when we enter the inset from the right by pressing "Left"
|
2001-09-26 16:52:34 +00:00
|
|
|
bool idxLast(idx_type & idx, pos_type & pos) const;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/// where should we go if we press home?
|
2001-09-26 16:52:34 +00:00
|
|
|
bool idxHome(idx_type & idx, pos_type & pos) const;
|
2001-11-26 13:35:08 +00:00
|
|
|
/// where should we go if we press end?
|
2001-09-26 16:52:34 +00:00
|
|
|
bool idxEnd(idx_type & idx, pos_type & pos) const;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/// number of cells currently governed by us
|
2001-09-26 16:52:34 +00:00
|
|
|
idx_type nargs() const;
|
2002-05-30 07:09:54 +00:00
|
|
|
/// access to the lock
|
|
|
|
bool lock() const;
|
|
|
|
/// access to the lock
|
|
|
|
void lock(bool);
|
2002-06-27 18:12:50 +00:00
|
|
|
/// get notification when the cursor leaves this inset
|
2002-10-29 08:23:32 +00:00
|
|
|
void notifyCursorLeaves(idx_type);
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/// direct access to the cell
|
2001-09-26 16:52:34 +00:00
|
|
|
MathArray & cell(idx_type);
|
2001-11-26 13:35:08 +00:00
|
|
|
/// direct access to the cell
|
2001-09-26 16:52:34 +00:00
|
|
|
MathArray const & cell(idx_type) const;
|
2002-03-21 17:42:56 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/// can we move into this cell (see macroarg.h)
|
2002-05-30 07:09:54 +00:00
|
|
|
bool isActive() const;
|
2001-11-26 13:35:08 +00:00
|
|
|
/// request "external features"
|
|
|
|
void validate(LaTeXFeatures & features) const;
|
|
|
|
|
|
|
|
/// match in all cells
|
2002-08-09 10:22:35 +00:00
|
|
|
bool match(MathAtom const &) const;
|
2001-11-26 13:35:08 +00:00
|
|
|
/// replace in all cells
|
2001-11-16 09:55:37 +00:00
|
|
|
void replace(ReplaceData &);
|
2002-02-01 17:01:30 +00:00
|
|
|
/// do we contain a given pattern?
|
2002-08-08 16:08:11 +00:00
|
|
|
bool contains(MathArray const &) const;
|
2002-06-18 15:44:30 +00:00
|
|
|
/// glue everything to a single cell
|
|
|
|
MathArray glue() const;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2001-11-26 13:35:08 +00:00
|
|
|
/// debug helper
|
|
|
|
void dump() const;
|
2002-06-14 10:48:27 +00:00
|
|
|
/// is the cursor currently somewhere within this inset?
|
2002-02-11 15:55:13 +00:00
|
|
|
virtual bool editing() const;
|
2001-08-03 17:10:22 +00:00
|
|
|
|
2002-08-01 15:53:46 +00:00
|
|
|
/// writes \\, name(), and args in braces and '\\lyxlock' if necessary
|
|
|
|
void write(WriteStream & os) const;
|
|
|
|
/// writes [, name(), and args in []
|
|
|
|
void normalize(NormalStream & os) const;
|
|
|
|
|
2002-08-15 10:02:53 +00:00
|
|
|
/// local dispatcher
|
|
|
|
result_type dispatch(FuncRequest const & cmd, idx_type & idx, pos_type & pos);
|
|
|
|
|
2001-08-03 17:10:22 +00:00
|
|
|
protected:
|
2001-11-26 13:35:08 +00:00
|
|
|
/// we store the cells in a vector
|
2002-08-02 14:29:42 +00:00
|
|
|
typedef std::vector<MathArray> cells_type;
|
2001-11-26 13:35:08 +00:00
|
|
|
/// thusly:
|
2001-08-03 17:10:22 +00:00
|
|
|
cells_type cells_;
|
2002-06-14 10:48:27 +00:00
|
|
|
/// if the inset is locked, it can't be entered with the cursor
|
2002-05-30 07:09:54 +00:00
|
|
|
bool lock_;
|
2001-08-03 17:10:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|