]> git.lyx.org Git - lyx.git/blob - src/mathed/math_iter.h
small cleanup, doxygen, formatting changes
[lyx.git] / src / mathed / math_iter.h
1 // -*- C++ -*-
2 /*
3  *  File:        math_iter.h
4  *  Purpose:     Iterator for Math paragraphs
5  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
6  *  Created:     January 1997
7  *  Description: Using iterators is the only way to handle math paragraphs 
8  *
9  *  Dependencies: Xlib
10  *
11  *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
12  *
13  *   Version: 0.8beta, Mathed & Lyx project.
14  *
15  *   You are free to use and modify this code under the terms of
16  *   the GNU General Public Licence version 2 or later.
17  * 
18  */
19
20 #ifndef MATH_ITER
21 #define MATH_ITER
22
23 #ifdef __GNUG__
24 #pragma interface
25 #endif
26
27 #include "mathed/support.h"
28 #include "math_defs.h"
29
30 class MathedInset;
31 class MathedArray;
32 class MathParInset;
33
34 ///
35 enum mathIterFlags {
36         /// Allow newlines
37         MthIF_CR = 1,
38         /// Allow tabs
39         MthIF_Tabs = 2
40 };
41
42
43 /** Specialized array iterator for math paragraph.
44     Used for storing and querying data operations
45 */
46 class MathedIter {
47 public:
48         ///
49         MathedIter();
50         ///
51         explicit
52         MathedIter(MathedArray *);
53         ///
54         virtual ~MathedIter() {}
55         ///
56         bool goNextCode(MathedTextCodes);
57         ///
58         void goPosAbs(int);
59         ///
60         int Empty() const;
61         ///
62         int OK() const;
63         ///
64         int IsFirst() const { return (pos == 0); }
65         ///
66         byte GetChar() const;
67         ///
68         string const GetString() const;
69         ///
70         MathedInset * GetInset() const;
71         ///
72         MathParInset * GetActiveInset() const;
73         ///
74         bool IsInset() const;
75         ///
76         bool IsActive() const;
77         ///
78         bool IsFont() const;
79         ///
80         bool IsScript() const;
81         ///
82         bool IsTab() const;
83         ///
84         bool IsCR() const;
85         ///
86         virtual void Reset();
87         ///
88         virtual void Insert(byte, MathedTextCodes c = LM_TC_CONST);
89         ///
90         virtual void Insert(MathedInset *, int t = LM_TC_INSET);
91         ///
92         virtual bool Delete();
93         ///
94         virtual bool Next();
95         /// Check consistency of tabs and newlines
96         void checkTabs();
97         /// Try to adjust tabs in the expected place, as in eqnarrays
98         void adjustTabs();
99         ///
100         short FCode() const { return fcode; }
101         ///
102         int getPos() const { return pos; }
103         ///
104         int getRow() const { return row; }
105         ///
106         int getCol() const { return col; }
107         ///
108         void setNumCols(int n) { ncols = n; }
109         ///
110         void SetData(MathedArray * a);
111         ///
112         MathedArray * GetData() const;
113         /// Copy every object from position p1 to p2
114         MathedArray * Copy(int p1 = 0, int p2 = 10000);
115         /// Delete every object from position p1 to p2
116         void Clear();
117 protected:
118         ///
119         void split(int);
120         ///
121         void join(int);
122         ///
123         int flags;
124         ///
125         mutable short fcode;
126         ///
127         mutable int pos;
128         ///
129         int row;
130         ///
131         int col;
132         ///
133         int ncols;
134         ///
135         MathedArray * array;
136         // one element stack
137         struct MIState {
138                 ///
139                 short fcode;
140                 ///
141                 int x;
142                 ///
143                 int y;
144                 ///
145                 int pos;
146                 ///
147                 int row;
148                 ///
149                 int col;
150         };
151         ///
152         MIState stck;
153         /// Saves the current state of the iterator
154         virtual void ipush();
155         /// Recover previous state
156         virtual void ipop();
157 };
158
159 ///
160 //#define MX_WAS_SUB   1
161 ///
162 //#define MX_WAS_SUPER 2
163
164 #endif