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