// -*- C++ -*- /* * File: math_iter.h * Purpose: Iterator for Math paragraphs * Author: Alejandro Aguilar Sierra <asierra@servidor.unam.mx> * Created: January 1997 * Description: Using iterators is the only way to handle math paragraphs * * Dependencies: Xlib * * Copyright: (c) 1996, 1997 Alejandro Aguilar Sierra * * Version: 0.8beta, Mathed & Lyx project. * * You are free to use and modify this code under the terms of * the GNU General Public Licence version 2 or later. *
*/
/** Specialized array iterator for amth paragraph. Used for storing and querying data operations
*/ class MathedIter { public: ///
MathedIter()
{
pos = 0;
fcode = 0;
array = NULL;
flags = 0;
ncols = row = col = 0;
} ///
MathedIter(LyxArrayBase *); /// virtual ~MathedIter() { } /// bool goNextCode(MathedTextCodes); /// void goPosRel(int); /// void goPosAbs(int); /// int Empty() { return array->last<=1; } /// int OK() { return array && (pos < array->last); } /// int IsFirst() { return (pos==0); } ///
byte GetChar(); ///
byte* GetString(int& len); ///
MathedInset* GetInset(); ///
MathParInset* GetActiveInset(); /// bool IsInset(); /// bool IsActive(); /// bool IsFont(); /// bool IsScript(); /// bool IsTab(); /// bool IsCR(); /// virtualvoid Reset(); /// virtualvoid Insert(byte, MathedTextCodes c=LM_TC_CONST); /// virtualvoid Insert(MathedInset*, int t=LM_TC_INSET); /// virtualboolDelete(); /// virtualbool Next(); /// Check consistency of tabs and newlines void checkTabs(); /// Try to adjust tabs in the expected place, as in eqnarrays void adjustTabs(); /// short FCode() const { return fcode; } /// int getPos() const { return pos; } /// int getRow() const { return row; } /// int getCol() const { return col; } /// void setNumCols(int n) { ncols = n; } /// void SetData(LyxArrayBase *a) { array = a; Reset(); } ///
LyxArrayBase *GetData() { return array; }
/// Copy every object from position p1 to p2
LyxArrayBase *Copy(int p1=0, int p2=10000);
/// Delete every object from position p1 to p2 void Clear();
protected: /// void split(int); /// void join(int); /// int flags; /// short fcode; /// int pos; /// int row, col, ncols; ///
LyxArrayBase *array; // one element stack struct MIState { /// short fcode; /// int x, y; /// int pos, row, col;
} stck;
/// Saves the current state of the iterator virtualvoid ipush(); /// Recover previous state virtualvoid ipop();
};
/** A graphic iterator (updates position.) Used for metrics and updating cursor position
*/ class MathedXIter: public MathedIter { public: ///
MathedXIter(): MathedIter() { x = y = size = 0; p = 0; crow = 0; } ///
MathedXIter(MathParInset*); ///
~MathedXIter() { }; /// void SetData(MathParInset *); ///
MathParInset *getPar() { return p; } /// bool Next(); /// bool Prev(); /// bool Up(); /// bool Down(); /// bool goNextColumn(); /// void GoLast(); /// void GoBegin(); /// void Adjust(); /// inlinevoid GetPos(int&, int&); /// inlinevoid GetIncPos(int&, int&); ///
byte* GetString(int&); /// int GetX(); /// int GetY(); /// void subMetrics(int, int); /// void fitCoord(int, int); /// void getAD(int& a, int& d);
/// Create a new row and insert #ncols# tabs. void addRow(); /// void delRow();
/**$ These two functions will be moved from here */ //@{ /// bool setLabel(char* label); /// bool setNumbered(bool); //@}
/// void setTab(int, int); /// Merge the array at current position void Merge(LyxArrayBase*); /// Delete every object from current position to pos2 void Clean(int pos2);
MathedRowSt *adjustVerticalSt();
private: /// This function is not recursive, as MathPar::Metrics is void IMetrics(int, int&, int&, int&); /// Font size (display, text, script, script2) int size; /// current position int x, y; // /// max ascent and descent // int asc, des; ///
MathParInset *p;
// Limits auxiliary variables /// Position and max width of a script int sx, sw; /// true=center, false=left align (default) bool limits; /// Type of previous script short s_type;
inline void MathedXIter::getAD(int& a, int& d)
{ if (crow) {
a = crow->asc;
d = crow->desc;
} else if (p) {
a = p->Ascent();
d = p->Descent();
} else {
a = d = 0;
}
}
#endif
¤ Dauer der Verarbeitung: 0.13 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.