]> git.lyx.org Git - lyx.git/blob - src/mathed/math_cursor.h
update libtool
[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_xiter.h"
27
28 class MathFuncInset;
29 class MathParInset;
30 class Painter;
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 insertInset(MathedInset *, int t);
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);
73         ///
74         short GetFCode();
75         ///
76         MathParInset * GetPar();
77         ///
78         MathParInset * getCurrentPar() const;
79         ///
80         void SetCursorData(MathParInset *);
81         ///
82         void SetPar(MathParInset *);
83         ///
84         void Interpret(string const &);
85         ///
86         void SetSize(short);
87         ///
88         void setNumbered();
89         ///
90         void setLabel(string const &);
91         ///
92         string const & getLabel() const;
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;
101         // Macro mode methods
102         ///
103         void MacroModeOpen();
104         ///
105         void MacroModeClose();
106         ///
107         bool InMacroMode();
108         
109         // Local selection methods
110         ///
111         bool 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();
130         ///
131         void setLastCode(MathedTextCodes t);
132         ///
133         void toggleLastCode(MathedTextCodes t);
134         ///
135         MathedTextCodes getLastCode() const;
136
137         /// true iff cursor points to data
138         bool hasData(MathedArray const &);
139         
140 //protected:
141         ///
142         bool macro_mode;
143         
144         // Selection stuff
145         ///
146         bool selection;
147         ///
148         int  selpos;
149         ///
150         MathedXIter cursel;
151         ///
152         MathedXIter * anchor;
153         ///
154         MathParInset * par;
155         ///
156         MathedXIter * cursor;
157         ///
158         void doAccent(byte c, MathedTextCodes t);
159         ///
160         void doAccent(MathedInset * p);
161         ///
162         int accent;
163         ///
164         int nestaccent[8];
165         ///
166         MathedTextCodes lastcode;
167         
168 private:
169         ///
170         MathFuncInset * imacro;
171 };
172
173 #endif