]> git.lyx.org Git - lyx.git/blob - src/mathed/math_iter.h
some inline fix + mathed16.diff
[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 "math_defs.h"
28
29 class MathedInset;
30
31 ///
32 enum mathIterFlags {
33         /// Allow newlines
34         MthIF_CR = 1,
35         /// Allow tabs
36         MthIF_Tabs = 2
37 };
38
39
40 /** Specialized array iterator for math paragraph.
41     Used for storing and querying data operations
42 */
43 class MathedIter {
44 public:
45         ///
46         MathedIter();
47         ///
48         explicit
49         MathedIter(MathedArray *);
50         ///
51         virtual ~MathedIter() {}
52         ///
53         bool goNextCode(MathedTextCodes);
54         ///
55         void goPosRel(int);
56         ///
57         void goPosAbs(int);
58         ///
59         int Empty() const;
60         ///
61         int OK() const;
62         ///
63         int IsFirst() const { return (pos == 0); }
64         ///
65         byte GetChar() const;
66         ///
67         string const GetString() const;
68         ///
69         MathedInset * GetInset() const;
70         ///
71         MathParInset * GetActiveInset() const;
72         ///
73         bool IsInset() const;
74         ///
75         bool IsActive() const;
76         ///
77         bool IsFont() const;
78         ///
79         bool IsScript() const;
80         ///
81         bool IsTab() const;
82         ///
83         bool IsCR() const;
84         ///
85         virtual void Reset();
86         ///
87         virtual void Insert(byte, MathedTextCodes c = LM_TC_CONST);
88         ///
89         virtual void Insert(MathedInset *, int t = LM_TC_INSET);
90         ///
91         virtual bool Delete();
92         ///
93         virtual bool Next();
94         /// Check consistency of tabs and newlines
95         void checkTabs();
96         /// Try to adjust tabs in the expected place, as in eqnarrays
97         void adjustTabs();
98         ///
99         short FCode() const { return fcode; }
100         ///
101         int getPos() const { return pos; }
102         ///
103         int getRow() const { return row; }
104         ///
105         int getCol() const { return col; }
106         ///
107         void setNumCols(int n) { ncols = n; }
108         ///
109         void SetData(MathedArray * a);
110         ///
111         MathedArray * GetData() const;
112         /// Copy every object from position p1 to p2
113         MathedArray * Copy(int p1 = 0, int p2 = 10000);
114         /// Delete every object from position p1 to p2
115         void Clear();
116 protected:
117         ///
118         void split(int);
119         ///
120         void join(int);
121         ///
122         int flags;
123         ///
124         mutable short fcode;
125         ///
126         mutable int pos;
127         ///
128         int row;
129         ///
130         int col;
131         ///
132         int ncols;
133         ///
134         MathedArray * array;
135         // one element stack
136         struct MIState {
137                 ///
138                 short fcode;
139                 ///
140                 int x;
141                 ///
142                 int y;
143                 ///
144                 int pos;
145                 ///
146                 int row;
147                 ///
148                 int col;
149         };
150         ///
151         MIState stck;
152         /// Saves the current state of the iterator
153         virtual void ipush();
154         /// Recover previous state
155         virtual void ipop();
156 };
157
158 ///
159 //#define MX_WAS_SUB   1
160 ///
161 //#define MX_WAS_SUPER 2
162
163 #endif