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