*
* Dependencies: Xlib
*
- * Copyright: (c) 1996, 1997 Alejandro Aguilar Sierra
+ * Copyright: 1996, 1997 Alejandro Aguilar Sierra
*
* Version: 0.8beta, Mathed & Lyx project.
*
*
*/
-#ifndef __MATH_ITER__
-#define __MATH_ITER__
+#ifndef MATH_ITER
+#define MATH_ITER
#ifdef __GNUG__
#pragma interface
///
enum mathIterFlags {
- /// Allow newlines
+ /// Allow newlines
MthIF_CR = 1,
/// Allow tabs
MthIF_Tabs = 2
};
-/**
- Specialized array iterator for amth paragraph. Used for
- storing and querying data operations
- */
+/** Specialized array iterator for math paragraph.
+ Used for storing and querying data operations
+*/
class MathedIter {
public:
///
- MathedIter()
- {
+ MathedIter() {
pos = 0;
fcode = 0;
array = 0;
ncols = row = col = 0;
}
///
+ explicit
MathedIter(LyxArrayBase *);
///
- virtual ~MathedIter() { }
+ virtual ~MathedIter() {}
///
bool goNextCode(MathedTextCodes);
///
- void goPosRel(int);
+ void goPosRel(int);
///
void goPosAbs(int);
///
- int Empty() { return array->last<=1; }
+ int Empty() { return array->Last()<= 1; }
///
- int OK() { return array && (pos < array->last); }
+ int OK() { return array && (pos < array->Last()); }
///
- int IsFirst() { return (pos==0); }
+ int IsFirst() { return (pos == 0); }
///
byte GetChar();
///
- byte* GetString(int& len);
+ byte * GetString(int& len);
///
- MathedInset* GetInset();
+ MathedInset * GetInset();
///
- MathParInset* GetActiveInset();
+ MathParInset * GetActiveInset();
///
bool IsInset();
///
///
virtual void Reset();
///
- virtual void Insert(byte, MathedTextCodes c=LM_TC_CONST);
+ virtual void Insert(byte, MathedTextCodes c = LM_TC_CONST);
///
- virtual void Insert(MathedInset*, int t=LM_TC_INSET);
+ virtual void Insert(MathedInset *, int t = LM_TC_INSET);
///
virtual bool Delete();
///
///
void setNumCols(int n) { ncols = n; }
///
- void SetData(LyxArrayBase *a) { array = a; Reset(); }
+ void SetData(LyxArrayBase * a) { array = a; Reset(); }
///
- LyxArrayBase *GetData() { return array; }
+ LyxArrayBase * GetData() { return array; }
/// Copy every object from position p1 to p2
- LyxArrayBase *Copy(int p1=0, int p2=10000);
+ LyxArrayBase * Copy(int p1= 0, int p2= 10000);
/// Delete every object from position p1 to p2
void Clear();
LyxArrayBase *array;
// one element stack
struct MIState {
- ///
+ ///
short fcode;
- ///
+ ///
int x, y;
- ///
+ ///
int pos, row, col;
- } stck;
-
+ };
+ ///
+ MIState stck;
/// Saves the current state of the iterator
virtual void ipush();
/// Recover previous state
class MathedXIter: public MathedIter {
public:
///
- MathedXIter(): MathedIter() { x = y = size = 0; p = 0; crow = 0; }
- ///
- MathedXIter(MathParInset*);
- ///
- ~MathedXIter() { };
+ MathedXIter()
+ : MathedIter(), sx(0), sw(0) {
+ x = y = size = 0; p = 0; crow = 0;
+ }
+ //
+ MathedXIter(MathParInset *);
///
void SetData(MathParInset *);
///
- MathParInset *getPar() { return p; }
+ MathParInset * getPar() { return p; }
///
bool Next();
///
///
void Adjust();
///
- inline void GetPos(int&, int&);
+ inline
+ void GetPos(int &, int &);
///
- inline void GetIncPos(int&, int&);
+ inline
+ void GetIncPos(int &, int &);
///
- byte* GetString(int&);
+ byte * GetString(int &);
///
int GetX();
///
///
void fitCoord(int, int);
///
- void getAD(int& a, int& d);
+ void getAD(int & a, int & d);
/// Create a new row and insert #ncols# tabs.
void addRow();
- ///
- void delRow();
+ ///
+ 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*);
void Clean(int pos2);
MathedRowSt *adjustVerticalSt();
- private:
+private:
/// This function is not recursive, as MathPar::Metrics is
void IMetrics(int, int&, int&, int&);
/// Font size (display, text, script, script2)
// Limits auxiliary variables
/// Position and max width of a script
int sx, sw;
- /// true=center, false=left align (default)
+ /// true= center, false= left align (default)
bool limits;
/// Type of previous script
short s_type;
-
+ ///
void ipush();
-
+ ///
void ipop();
- protected:
+protected:
///
MathedRowSt *crow;
- private:
+private:
///
friend class MathedCursor;
};
inline
bool MathedIter::IsInset()
{
- return MathIsInset(array->bf[pos]);
+ return MathIsInset((*array)[pos]);
}
inline
bool MathedIter::IsActive()
{
- return MathIsActive(array->bf[pos]);
+ return MathIsActive((*array)[pos]);
}
inline
bool MathedIter::IsFont()
{
- return MathIsFont(array->bf[pos]);
+ return MathIsFont((*array)[pos]);
}
inline
bool MathedIter::IsScript()
{
- return MathIsScript(array->bf[pos]);
+ return MathIsScript((*array)[pos]);
}
inline
bool MathedIter::IsTab()
{
- return (array->bf[pos]==LM_TC_TAB);
+ return ((*array)[pos] == LM_TC_TAB);
}
inline
bool MathedIter::IsCR()
{
- return (array->bf[pos]==LM_TC_CR);
+ return ((*array)[pos] == LM_TC_CR);
}
inline
-MathedIter::MathedIter(LyxArrayBase *d): array(d)
+MathedIter::MathedIter(LyxArrayBase * d): array(d)
{
pos = 0;
row = col = 0;
- fcode = (array && IsFont()) ? array->bf[0]: 0;
+ fcode = (array && IsFont()) ? (*array)[0]: 0;
}