]> git.lyx.org Git - lyx.git/blob - src/mathed/math_cursor.h
mathed20.diff
[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 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);
73         ///
74         short GetFCode();
75         ///
76         MathParInset * GetPar();
77         ///
78         MathParInset * getCurrentPar() const;
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         ///
92         bool Limits();
93         /// Set accent: if argument = 0 it's considered consumed 
94         void setAccent(int ac = 0);
95         /// Returns last accent
96         int getAccent() const;
97         ///
98         bool IsEnd() const;
99         // Macro mode methods
100         ///
101         void MacroModeOpen();
102         ///
103         void MacroModeClose();
104         ///
105         bool InMacroMode();
106         
107         // Local selection methods
108         ///
109         bool Selection();
110         ///
111         void SelCopy();
112         ///
113         void SelCut();
114         ///
115         void SelDel();
116         ///
117         void SelPaste();
118         ///
119         void SelStart();
120         ///
121         void SelClear();
122         ///
123         void SelBalance();
124         ///
125         void SelGetArea(int ** xp, int ** yp, int & n);
126         ///
127         void clearLastCode();
128         ///
129         void setLastCode(MathedTextCodes t);
130         ///
131         void toggleLastCode(MathedTextCodes t);
132         ///
133         MathedTextCodes getLastCode() const;
134         
135 protected:
136         ///
137         bool macro_mode;
138         
139         // Selection stuff
140         ///
141         bool selection;
142         ///
143         int  selpos;
144         ///
145         MathedXIter cursel;
146         ///
147         MathedXIter * anchor;
148         ///
149         MathParInset * par;
150         ///
151         MathedXIter * cursor;
152         ///
153         void doAccent(byte c, MathedTextCodes t);
154         ///
155         void doAccent(MathedInset * p);
156         ///
157         int accent;
158         ///
159         int nestaccent[8];
160         ///
161         MathedTextCodes lastcode;
162         
163 private:
164         ///
165         MathFuncInset * imacro;
166 };
167
168 #endif