1999-09-27 18:44:28 +00:00
|
|
|
// -*- C++ -*-
|
2002-09-11 08:26:02 +00:00
|
|
|
/**
|
2007-04-26 16:05:57 +00:00
|
|
|
* \file MathData.h
|
2003-08-19 13:00:56 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-09-11 08:26:02 +00:00
|
|
|
*
|
2003-08-19 13:00:56 +00:00
|
|
|
* \author Alejandro Aguilar Sierra
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author André Pönitz
|
|
|
|
* \author Lars Gullik Bjønnes
|
2007-11-01 11:13:07 +00:00
|
|
|
* \author Stefan Schimanski
|
2003-08-19 13:00:56 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
2002-08-02 14:29:42 +00:00
|
|
|
|
2001-12-10 10:09:00 +00:00
|
|
|
#ifndef MATH_DATA_H
|
|
|
|
#define MATH_DATA_H
|
2001-02-12 08:55:14 +00:00
|
|
|
|
2007-04-26 04:41:58 +00:00
|
|
|
#include "Dimension.h"
|
2007-11-01 11:13:07 +00:00
|
|
|
#include "MathAtom.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2010-01-28 17:37:22 +00:00
|
|
|
#include "OutputEnums.h"
|
|
|
|
|
2007-11-05 22:54:53 +00:00
|
|
|
#include "support/strfwd.h"
|
|
|
|
|
2011-02-12 22:10:56 +00:00
|
|
|
#include <cstddef>
|
2007-11-05 22:54:53 +00:00
|
|
|
#include <vector>
|
2006-10-19 16:51:30 +00:00
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
2009-11-08 11:45:46 +00:00
|
|
|
class Buffer;
|
2006-10-13 16:44:44 +00:00
|
|
|
class BufferView;
|
2007-11-05 22:54:53 +00:00
|
|
|
class Cursor;
|
2007-12-21 20:42:46 +00:00
|
|
|
class DocIterator;
|
2001-11-08 12:06:56 +00:00
|
|
|
class LaTeXFeatures;
|
2001-11-16 09:55:37 +00:00
|
|
|
class ReplaceData;
|
2007-12-21 20:42:46 +00:00
|
|
|
class MacroContext;
|
2007-11-01 11:13:07 +00:00
|
|
|
class MathMacro;
|
2003-03-21 14:20:48 +00:00
|
|
|
class MetricsInfo;
|
|
|
|
class PainterInfo;
|
2010-01-28 17:37:22 +00:00
|
|
|
class ParIterator;
|
2002-08-02 14:29:42 +00:00
|
|
|
class TextMetricsInfo;
|
|
|
|
class TextPainter;
|
2001-11-08 12:06:56 +00:00
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
2007-04-26 16:05:57 +00:00
|
|
|
class MathData : private std::vector<MathAtom> {
|
2001-08-09 08:53:16 +00:00
|
|
|
public:
|
2002-07-30 13:56:02 +00:00
|
|
|
/// re-use inhertited stuff
|
|
|
|
typedef std::vector<MathAtom> base_type;
|
|
|
|
using base_type::const_iterator;
|
|
|
|
using base_type::iterator;
|
|
|
|
using base_type::size_type;
|
|
|
|
using base_type::difference_type;
|
|
|
|
using base_type::size;
|
|
|
|
using base_type::empty;
|
|
|
|
using base_type::clear;
|
|
|
|
using base_type::begin;
|
|
|
|
using base_type::end;
|
|
|
|
using base_type::push_back;
|
|
|
|
using base_type::pop_back;
|
|
|
|
using base_type::back;
|
|
|
|
using base_type::front;
|
|
|
|
///
|
|
|
|
typedef size_type idx_type;
|
|
|
|
typedef size_type pos_type;
|
2002-12-01 22:59:25 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
public:
|
2001-02-09 17:17:08 +00:00
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
MathData(Buffer * buf = 0) : buffer_(buf) {}
|
2001-02-19 14:16:57 +00:00
|
|
|
///
|
2009-11-08 11:45:46 +00:00
|
|
|
MathData(Buffer * buf, const_iterator from, const_iterator to);
|
|
|
|
///
|
|
|
|
Buffer * buffer() { return buffer_; }
|
|
|
|
///
|
|
|
|
Buffer const * buffer() const { return buffer_; }
|
2001-11-09 10:44:24 +00:00
|
|
|
///
|
2007-04-26 16:05:57 +00:00
|
|
|
void append(MathData const & ar);
|
2002-03-21 17:42:56 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// inserts single atom at position pos
|
|
|
|
void insert(size_type pos, MathAtom const & at);
|
|
|
|
/// inserts multiple atoms at position pos
|
2007-04-26 16:05:57 +00:00
|
|
|
void insert(size_type pos, MathData const & ar);
|
2001-02-14 17:50:58 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// erase range from pos1 to pos2
|
2001-11-09 10:44:24 +00:00
|
|
|
void erase(iterator pos1, iterator pos2);
|
2002-06-18 15:44:30 +00:00
|
|
|
/// erase single atom
|
2001-11-09 10:44:24 +00:00
|
|
|
void erase(iterator pos);
|
2002-06-18 15:44:30 +00:00
|
|
|
/// erase range from pos1 to pos2
|
2001-09-14 14:05:57 +00:00
|
|
|
void erase(size_type pos1, size_type pos2);
|
2002-06-18 15:44:30 +00:00
|
|
|
/// erase single atom
|
2001-09-14 14:05:57 +00:00
|
|
|
void erase(size_type pos);
|
2001-11-09 16:27:44 +00:00
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
///
|
2001-11-08 12:06:56 +00:00
|
|
|
void dump() const;
|
2001-02-12 08:55:14 +00:00
|
|
|
///
|
2001-11-08 12:06:56 +00:00
|
|
|
void dump2() const;
|
2001-02-12 08:55:14 +00:00
|
|
|
///
|
2001-11-16 09:55:37 +00:00
|
|
|
void replace(ReplaceData &);
|
2004-04-13 06:27:29 +00:00
|
|
|
///
|
2007-04-26 16:05:57 +00:00
|
|
|
void substitute(MathData const & m);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
/// looks for exact match
|
2007-04-26 16:05:57 +00:00
|
|
|
bool match(MathData const & ar) const;
|
2002-06-18 15:44:30 +00:00
|
|
|
/// looks for inclusion match starting at pos
|
2007-04-26 16:05:57 +00:00
|
|
|
bool matchpart(MathData const & ar, pos_type pos) const;
|
2002-06-18 15:44:30 +00:00
|
|
|
/// looks for containment, return == size mean not found
|
2007-04-26 16:05:57 +00:00
|
|
|
size_type find(MathData const & ar) const;
|
2002-06-18 15:44:30 +00:00
|
|
|
/// looks for containment, return == size mean not found
|
2007-04-26 16:05:57 +00:00
|
|
|
size_type find_last(MathData const & ar) const;
|
2001-02-12 08:55:14 +00:00
|
|
|
///
|
2007-04-26 16:05:57 +00:00
|
|
|
bool contains(MathData const & ar) const;
|
2002-06-18 15:44:30 +00:00
|
|
|
///
|
|
|
|
void validate(LaTeXFeatures &) const;
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
/// checked write access
|
|
|
|
MathAtom & operator[](pos_type);
|
|
|
|
/// checked read access
|
|
|
|
MathAtom const & operator[](pos_type) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// rebuild cached metrics information
|
2007-09-21 20:39:47 +00:00
|
|
|
void metrics(MetricsInfo & mi, Dimension & dim) const;
|
|
|
|
///
|
2007-09-24 13:52:04 +00:00
|
|
|
Dimension const & dimension(BufferView const &) const;
|
2007-09-21 20:39:47 +00:00
|
|
|
|
2002-08-02 14:29:42 +00:00
|
|
|
/// redraw cell using cache metrics information
|
2003-03-21 14:20:48 +00:00
|
|
|
void draw(PainterInfo & pi, int x, int y) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// rebuild cached metrics information
|
2003-05-28 13:22:36 +00:00
|
|
|
void metricsT(TextMetricsInfo const & mi, Dimension & dim) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// redraw cell using cache metrics information
|
|
|
|
void drawT(TextPainter & pi, int x, int y) const;
|
|
|
|
/// mark cell for re-drawing
|
|
|
|
void touch() const;
|
|
|
|
|
|
|
|
/// access to cached x coordinate of last drawing
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
int xo(BufferView const & bv) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// access to cached y coordinate of last drawing
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
int yo(BufferView const & bv) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// access to cached x coordinate of mid point of last drawing
|
2007-09-24 13:52:04 +00:00
|
|
|
int xm(BufferView const & bv) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// access to cached y coordinate of mid point of last drawing
|
2007-09-24 13:52:04 +00:00
|
|
|
int ym(BufferView const & bv) const;
|
2002-08-09 08:14:18 +00:00
|
|
|
/// write access to coordinate;
|
2006-10-13 16:44:44 +00:00
|
|
|
void setXY(BufferView & bv, int x, int y) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// returns x coordinate of given position in the array
|
2007-12-24 10:52:58 +00:00
|
|
|
int pos2x(BufferView const * bv, size_type pos) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// returns position of given x coordinate
|
2007-12-24 10:52:58 +00:00
|
|
|
int pos2x(BufferView const * bv, size_type pos, int glue) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// returns position of given x coordinate
|
2007-12-24 10:52:58 +00:00
|
|
|
size_type x2pos(BufferView const * bv, int pos) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// returns position of given x coordinate fstarting from a certain pos
|
2007-12-24 10:52:58 +00:00
|
|
|
size_type x2pos(BufferView const * bv, int targetx, int glue) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
/// returns distance of this cell to the point given by x and y
|
|
|
|
// assumes valid position and size cache
|
Move BufferView cached pointer out of LyXText:
* LyXText
- bv(), bv_owner, : deleted.
- These methods now need a (Buffer const &) argument: getFont(), applyOuterFont(), getLayoutFont(), getLabelFont(), setCharFont(), setLayout(), singleWidth(), leftMargin(), rightMargin(), computeRowMetrics(), isMainText(), spacing(), isRTL(), cursorX(), rowBreakPoint(), setRowWidth(), labelFill(), labelEnd().
- These methods now need a (BufferView const &) argument and are propably candidates for future removal when 1.6 is opened for development: redoParagraph(), x2pos(), getRowNearY(), getColumnNearX(), checkInsetHit(), setHeightOfRow().
- recUndo(): now need a LCursor argument.
* CoordCache::get(LyXText const *, pit_type):
- now const.
- use const_iterator instead of iterator.
* FontIterator:
- add (Buffer const &) argument to ctor
- buffer_: new const reference to applicable BufferView.
* InsetBase
- xo(), yo(), covers() and neverIndent() are now const.
* InsetText::setViewCache(): deleted
All other changes are due to the LyXText and InsetBase API changes.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15618 a592a061-630c-0410-9148-cb99ea01b6c8
2006-10-30 12:45:33 +00:00
|
|
|
int dist(BufferView const & bv, int x, int y) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
|
2007-03-18 15:00:57 +00:00
|
|
|
/// minimum ascent offset for superscript
|
|
|
|
int minasc() const { return minasc_; }
|
|
|
|
/// minimum descent offset for subscript
|
|
|
|
int mindes() const { return mindes_; }
|
|
|
|
/// level above/below which super/subscript should extend
|
|
|
|
int slevel() const { return slevel_; }
|
|
|
|
/// additional super/subscript shift
|
|
|
|
int sshift() const { return sshift_; }
|
2007-03-21 17:21:59 +00:00
|
|
|
/// superscript kerning
|
2008-01-03 15:44:05 +00:00
|
|
|
int kerning(BufferView const *) const { return kerning_; }
|
2007-05-28 22:27:45 +00:00
|
|
|
///
|
2007-04-26 16:05:57 +00:00
|
|
|
void swap(MathData & ar) { base_type::swap(ar); }
|
2007-04-17 16:49:17 +00:00
|
|
|
|
2007-12-21 20:42:46 +00:00
|
|
|
/// attach/detach arguments to macros, updating the cur to
|
|
|
|
/// stay visually at the same position (cur==0 is allowed)
|
|
|
|
void updateMacros(Cursor * cur, MacroContext const & mc);
|
2010-01-28 17:37:22 +00:00
|
|
|
///
|
2010-03-03 22:13:45 +00:00
|
|
|
void updateBuffer(ParIterator const &, UpdateType);
|
2007-12-21 20:42:46 +00:00
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
protected:
|
2007-03-18 15:00:57 +00:00
|
|
|
/// cached values for super/subscript placement
|
|
|
|
mutable int minasc_;
|
|
|
|
mutable int mindes_;
|
|
|
|
mutable int slevel_;
|
|
|
|
mutable int sshift_;
|
2007-03-21 17:21:59 +00:00
|
|
|
mutable int kerning_;
|
2009-11-08 11:45:46 +00:00
|
|
|
Buffer * buffer_;
|
|
|
|
|
2001-08-09 08:53:16 +00:00
|
|
|
private:
|
2002-06-18 15:44:30 +00:00
|
|
|
/// is this an exact match at this position?
|
2007-04-26 16:05:57 +00:00
|
|
|
bool find1(MathData const & ar, size_type pos) const;
|
2007-09-21 20:39:47 +00:00
|
|
|
|
2007-11-01 11:13:07 +00:00
|
|
|
///
|
2010-01-03 11:00:21 +00:00
|
|
|
void detachMacroParameters(DocIterator * dit, const size_type macroPos);
|
2007-11-01 11:13:07 +00:00
|
|
|
///
|
2007-12-21 20:42:46 +00:00
|
|
|
void attachMacroParameters(Cursor * cur, const size_type macroPos,
|
2007-11-01 11:13:07 +00:00
|
|
|
const size_type macroNumArgs, const int macroOptionals,
|
2008-03-04 14:49:03 +00:00
|
|
|
const bool fromInitToNormalMode, const bool interactiveInit,
|
|
|
|
const size_t appetite);
|
2007-11-01 14:40:15 +00:00
|
|
|
///
|
2007-12-21 20:42:46 +00:00
|
|
|
void collectOptionalParameters(Cursor * cur,
|
2007-11-01 14:40:15 +00:00
|
|
|
const size_type numOptionalParams, std::vector<MathData> & params,
|
2008-01-22 17:26:54 +00:00
|
|
|
size_t & pos, MathAtom & scriptToPutAround,
|
|
|
|
const pos_type macroPos, const int thisPos, const int thisSlice);
|
2007-11-01 14:40:15 +00:00
|
|
|
///
|
2007-12-21 20:42:46 +00:00
|
|
|
void collectParameters(Cursor * cur,
|
2007-11-01 14:40:15 +00:00
|
|
|
const size_type numParams, std::vector<MathData> & params,
|
|
|
|
size_t & pos, MathAtom & scriptToPutAround,
|
2008-03-04 14:49:03 +00:00
|
|
|
const pos_type macroPos, const int thisPos, const int thisSlice,
|
|
|
|
const size_t appetite);
|
1999-09-27 18:44:28 +00:00
|
|
|
};
|
2001-04-24 16:13:38 +00:00
|
|
|
|
2001-12-11 10:14:51 +00:00
|
|
|
///
|
2007-04-26 16:05:57 +00:00
|
|
|
std::ostream & operator<<(std::ostream & os, MathData const & ar);
|
2006-10-19 16:51:30 +00:00
|
|
|
///
|
2007-04-26 16:05:57 +00:00
|
|
|
odocstream & operator<<(odocstream & os, MathData const & ar);
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
2001-12-11 10:14:51 +00:00
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
#endif
|