// -*- C++ -*- /** * \file MathRow.h * This file is part of LyX, the document processor. * Licence details can be found in the file COPYING. * * \author Jean-Marc Lasgouttes * * Full author contact details are available in file CREDITS. */ #ifndef MATH_ROW_H #define MATH_ROW_H #include "MathClass.h" #include "support/docstring.h" #include namespace lyx { class BufferView; class Dimension; class MetricsInfo; class PainterInfo; class InsetMath; class MathData; class MathMacro; /* * While for editing purpose it is important that macros are counted * as a single element, this is not the case for display. To get the * spacing correct, it is necessary to dissolve all the macros that * can be, along with their arguments. Then one obtains a * representation of the MathData contents as a string of insets and * then spacing can be done properly. * * This is the purpose of the MathRow class. */ class MathRow { public: // What row elements can be enum Type { INSET, // this element is a plain inset BEG_MACRO, // a macro begins here END_MACRO, // a macro ends here BEG_ARG, // a macro argument begins here END_ARG, // a macro argument ends here BEGIN, // dummy element before row END, // dummy element after row }; // An elements, together with its spacing struct Element { /// Element(Type t = INSET, MathClass const mc = MC_ORD); /// Classifies the contents of the object Type type; /// When type is INSET /// the math inset InsetMath const * inset; /// the class of the inset MathClass mclass; /// the spacing around the inset int before, after; // Non empty when there is a completion to draw docstring compl_text; // the number of characters forming the unique part. size_t compl_unique_to; /// When type is BEG_MACRO, END_MACRO, BEG_ARG, END_ARG /// the math macro MathMacro const * macro; // type is BEG_ARG, END_ARG MathData const * ar; }; /// MathRow() {}; /// typedef std::vector Elements; /// typedef Elements::iterator iterator; /// typedef Elements::const_iterator const_iterator; /// iterator begin() { return elements_.begin(); } /// iterator end() { return elements_.end(); } /// const_iterator begin() const { return elements_.begin(); } /// const_iterator end() const { return elements_.end(); } // void push_back(Element const & e) { elements_.push_back(e); } // Element & back() { return elements_.back(); } // create the math row by unwinding all macros in the MathData and // compute the spacings. MathRow(MetricsInfo const & mi, MathData const * ar); // void metrics(MetricsInfo & mi, Dimension & dim) const; // void draw(PainterInfo & pi, int const x, int const y) const; /// superscript kerning int kerning(BufferView const *) const; private: // Index of the first inset element before position i int before(int i) const; // Index of the first inset element after position i int after(int i) const; /// Elements elements_; }; /// std::ostream & operator<<(std::ostream & os, MathRow::Element const & elt); /// std::ostream & operator<<(std::ostream & os, MathRow const & mrow); } // namespace lyx #endif