1999-09-27 18:44:28 +00:00
|
|
|
|
// -*- C++ -*-
|
2002-09-11 08:26:02 +00:00
|
|
|
|
/**
|
2007-04-25 16:11:45 +00:00
|
|
|
|
* \file MathArray.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
|
|
|
|
|
* \author Andr<EFBFBD> P<EFBFBD>nitz
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
|
|
|
|
*
|
|
|
|
|
* 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
|
|
|
|
|
2001-02-09 17:17:08 +00:00
|
|
|
|
#include <vector>
|
2001-11-07 08:51:35 +00:00
|
|
|
|
|
2006-09-17 09:14:18 +00:00
|
|
|
|
#include "MathAtom.h"
|
2002-08-02 14:29:42 +00:00
|
|
|
|
#include "dimension.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
2006-10-19 16:51:30 +00:00
|
|
|
|
#include "support/docstream.h"
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
|
|
|
|
|
|
namespace lyx {
|
|
|
|
|
|
2006-10-13 16:44:44 +00:00
|
|
|
|
class BufferView;
|
2001-11-08 12:06:56 +00:00
|
|
|
|
class LaTeXFeatures;
|
2001-11-16 09:55:37 +00:00
|
|
|
|
class ReplaceData;
|
2003-03-21 14:20:48 +00:00
|
|
|
|
class MetricsInfo;
|
|
|
|
|
class PainterInfo;
|
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
|
|
|
|
|
2002-07-30 13:56:02 +00:00
|
|
|
|
class MathArray : 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
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
MathArray() {}
|
2001-02-19 14:16:57 +00:00
|
|
|
|
///
|
2002-07-30 13:56:02 +00:00
|
|
|
|
MathArray(const_iterator from, const_iterator to);
|
2001-11-09 10:44:24 +00:00
|
|
|
|
///
|
2002-07-30 13:56:02 +00:00
|
|
|
|
void append(MathArray 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
|
|
|
|
|
void insert(size_type pos, MathArray 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
|
|
|
|
///
|
|
|
|
|
void substitute(MathArray const & m);
|
2001-06-25 00:06:33 +00:00
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
/// looks for exact match
|
|
|
|
|
bool match(MathArray const & ar) const;
|
|
|
|
|
/// looks for inclusion match starting at pos
|
|
|
|
|
bool matchpart(MathArray const & ar, pos_type pos) const;
|
|
|
|
|
/// looks for containment, return == size mean not found
|
|
|
|
|
size_type find(MathArray const & ar) const;
|
|
|
|
|
/// looks for containment, return == size mean not found
|
|
|
|
|
size_type find_last(MathArray const & ar) const;
|
2001-02-12 08:55:14 +00:00
|
|
|
|
///
|
2002-06-18 15:44:30 +00:00
|
|
|
|
bool contains(MathArray const & ar) const;
|
|
|
|
|
///
|
|
|
|
|
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
|
2003-05-28 13:22:36 +00:00
|
|
|
|
void metrics(MetricsInfo & mi) const;
|
|
|
|
|
/// rebuild cached metrics information
|
2006-11-28 15:15:49 +00:00
|
|
|
|
bool metrics(MetricsInfo & mi, Dimension & dim) const;
|
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
|
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 xm(BufferView const & bv) const { return xo(bv) + dim_.wid / 2; }
|
2002-08-02 14:29:42 +00:00
|
|
|
|
/// access to cached y coordinate of mid point 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 ym(BufferView const & bv) const { return yo(bv) + (dim_.des - dim_.asc) / 2; }
|
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
|
|
|
|
|
int pos2x(size_type pos) const;
|
|
|
|
|
/// returns position of given x coordinate
|
2003-04-14 06:17:19 +00:00
|
|
|
|
int pos2x(size_type pos, int glue) const;
|
2002-08-02 14:29:42 +00:00
|
|
|
|
/// returns position of given x coordinate
|
|
|
|
|
size_type x2pos(int pos) const;
|
|
|
|
|
/// returns position of given x coordinate fstarting from a certain pos
|
2003-04-14 06:17:19 +00:00
|
|
|
|
size_type x2pos(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
|
|
|
|
|
|
|
|
|
/// ascent of this cell above the baseline
|
2003-05-27 13:55:03 +00:00
|
|
|
|
int ascent() const { return dim_.asc; }
|
2002-08-02 14:29:42 +00:00
|
|
|
|
/// descent of this cell below the baseline
|
2003-05-27 13:55:03 +00:00
|
|
|
|
int descent() const { return dim_.des; }
|
2002-08-02 14:29:42 +00:00
|
|
|
|
/// height of the cell
|
2003-05-27 13:55:03 +00:00
|
|
|
|
int height() const { return dim_.asc + dim_.des; }
|
2002-08-02 14:29:42 +00:00
|
|
|
|
/// width of this cell
|
2003-05-27 13:55:03 +00:00
|
|
|
|
int width() const { return dim_.wid; }
|
2002-08-02 14:29:42 +00:00
|
|
|
|
/// dimensions of cell
|
2003-05-28 13:22:36 +00:00
|
|
|
|
Dimension const & dim() const { return dim_; }
|
2002-08-02 14:29:42 +00:00
|
|
|
|
/// dimensions of cell
|
|
|
|
|
void setDim(Dimension const & d) const { dim_ = d; }
|
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
|
|
|
|
|
int kerning() const { return kerning_; }
|
2007-03-27 14:33:19 +00:00
|
|
|
|
///
|
|
|
|
|
void swap(MathArray & ar) { base_type::swap(ar); }
|
2007-04-17 16:49:17 +00:00
|
|
|
|
|
2006-11-28 15:15:49 +00:00
|
|
|
|
protected:
|
|
|
|
|
/// cached dimensions of cell
|
|
|
|
|
mutable Dimension dim_;
|
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_;
|
2006-11-28 15:15:49 +00:00
|
|
|
|
|
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?
|
|
|
|
|
bool find1(MathArray const & ar, size_type pos) const;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
};
|
2001-04-24 16:13:38 +00:00
|
|
|
|
|
2001-12-11 10:14:51 +00:00
|
|
|
|
///
|
|
|
|
|
std::ostream & operator<<(std::ostream & os, MathArray const & ar);
|
2006-10-19 16:51:30 +00:00
|
|
|
|
///
|
2006-10-21 00:16:43 +00:00
|
|
|
|
odocstream & operator<<(odocstream & os, MathArray const & ar);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace lyx
|
2001-12-11 10:14:51 +00:00
|
|
|
|
|
2001-02-12 08:55:14 +00:00
|
|
|
|
#endif
|