]> git.lyx.org Git - lyx.git/blob - src/mathed/math_cursor.h
5f6721553df29d2dcd4706600660d1b36c947253
[lyx.git] / src / mathed / math_cursor.h
1 // -*- C++ -*-
2 /*
3  *  File:        math_cursor.h
4  *  Purpose:     Declaration of interaction classes for mathed
5  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
6  *  Created:     January 1996
7  *  Description: MathCursor control all user interaction
8  *
9  *  Dependencies: Xlib, XForms
10  *
11  *  Copyright: 1996, 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 #ifndef MATH_CURSOR
20 #define MATH_CURSOR
21
22 #ifdef __GNUG__
23 #pragma interface
24 #endif
25
26 #include "math_iter.h" 
27 //#include "math_inset.h"
28 #include "math_xiter.h"
29
30 class MathFuncInset;
31
32
33 /// This is the external interface of Mathed's subkernel
34 class MathedCursor {
35 public:
36         ///
37         explicit
38         MathedCursor(MathParInset * p);
39         ///
40         void Insert(byte, MathedTextCodes t = LM_TC_MIN);
41         ///
42         void Insert(MathedInset *, int t = LM_TC_INSET);
43         ///
44         void Home();
45         ///
46         void End();
47         ///
48         bool Right(bool sel = false);
49         ///
50         bool Left(bool sel = false);
51         ///
52         bool Up(bool sel = false);
53         ///
54         bool Down(bool sel = false);
55         ///
56         bool Pop();
57         ///
58         bool Push();
59         /// Pull out an argument from its container inset
60         bool pullArg();
61         ///
62         void draw(Painter &, int x, int y);
63         ///
64         void Redraw(Painter &);
65         ///
66         void Delete();
67         ///
68         void DelLine();
69         ///
70         void SetPos(int, int);
71         ///
72         void GetPos(int & x, int & y) { cursor->GetPos(x, y); }
73         ///
74         short GetFCode() { return cursor->FCode(); }
75         ///
76         MathParInset * GetPar() { return par; }
77         ///
78         MathParInset * getCurrentPar() const { return cursor->p; }
79         ///
80         void SetPar(MathParInset *);
81         ///
82         void Interpret(string const &);
83         ///
84         void SetSize(short);
85         ///
86         void setNumbered();
87         ///
88         void setLabel(string const &);
89         ///
90         string const & getLabel() const {
91                 return cursor->getLabel();
92         }
93         ///
94         bool Limits();
95         /// Set accent: if argument = 0 it's considered consumed 
96         void setAccent(int ac = 0);
97         /// Returns last accent
98         int getAccent() const;
99         ///
100         bool IsEnd() const { return !cursor->OK(); }
101         // Macro mode methods
102         ///
103         void MacroModeOpen();
104         ///
105         void MacroModeClose();
106         ///
107         bool InMacroMode() { return macro_mode; }
108         
109         // Local selection methods
110         ///
111         bool Selection() { return selection; }
112         ///
113         void SelCopy();
114         ///
115         void SelCut();
116         ///
117         void SelDel();
118         ///
119         void SelPaste();
120         ///
121         void SelStart();
122         ///
123         void SelClear();
124         ///
125         void SelBalance();
126         ///
127         void SelGetArea(int ** xp, int ** yp, int & n);
128         ///
129         void clearLastCode() { lastcode = LM_TC_MIN; }
130         ///
131         void setLastCode(MathedTextCodes t) { lastcode = t; }
132         ///
133         void toggleLastCode(MathedTextCodes t);
134         ///
135         MathedTextCodes getLastCode() const { return lastcode; }
136         
137 protected:
138         ///
139         bool macro_mode;
140         ///
141         void MacroModeBack();
142         ///
143         void MacroModeInsert(char);
144         
145         // Selection stuff
146         ///
147         bool selection;
148         ///
149         int  selpos;
150         ///
151         MathedXIter cursel;
152         ///
153         MathedXIter * anchor;
154         ///
155 //    MathedArray *selarray; 
156         ///
157         bool is_visible;
158         ///
159         long unsigned win;
160         ///
161         MathParInset * par;
162         ///
163         MathedXIter * cursor;
164         ///
165         int xc;
166         ///
167         int yc;
168         ///
169         void doAccent(byte c, MathedTextCodes t);
170         ///
171         void doAccent(MathedInset * p);
172         ///
173         int accent;
174         ///
175         int nestaccent[8];
176         ///
177         MathedTextCodes lastcode;
178         
179 private:
180         ///
181         MathFuncInset * imacro;
182 };
183
184 #endif