]> git.lyx.org Git - lyx.git/blob - src/mathed/math_cursor.h
use the new sstream return non-pods as const, use string instead of char * in a lot...
[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(string const &);
80     ///
81     void SetSize(short);
82     ///
83     void setNumbered();
84     ///
85     void setLabel(string const &);
86     ///
87     bool Limits();
88     /// Set accent: if argument = 0 it's considered consumed 
89     void setAccent(int ac = 0);
90     /// Returns last accent
91     int getAccent() const;
92     ///
93     bool IsEnd() const { return !cursor->OK(); }
94     // Macro mode methods
95     ///
96     void MacroModeOpen();
97     ///
98     void MacroModeClose();
99     ///
100     bool InMacroMode() { return macro_mode; }
101     
102     // Local selection methods
103     ///
104     bool Selection() { return selection; }
105     ///
106     void SelCopy();
107     ///
108     void SelCut();
109     ///
110     void SelDel();
111     ///
112     void SelPaste();
113     ///
114     void SelStart();
115     ///
116     void SelClear();
117     ///
118     void SelBalance();
119     ///
120     void SelGetArea(int ** xp, int ** yp, int & n);
121     ///
122     void clearLastCode() { lastcode = LM_TC_MIN; }
123     ///
124     void setLastCode(MathedTextCodes t) { lastcode = t; }
125     ///
126     MathedTextCodes getLastCode() const { return lastcode; }
127     
128  protected:
129     ///
130     bool macro_mode;
131     ///
132     void MacroModeBack();
133     ///
134     void MacroModeInsert(char);
135     
136     // Selection stuff
137     ///
138     bool selection;
139     ///
140     int  selpos;
141     ///
142     MathedXIter cursel, * anchor;
143     ///
144 //    LyxArrayBase *selarray; 
145     ///
146     Bool is_visible;
147     ///
148     long unsigned win;
149     ///
150     MathParInset * par;
151     ///
152     MathedXIter * cursor;
153     ///
154     int xc, yc;
155     ///
156     void doAccent(byte c, MathedTextCodes t);
157     ///
158     void doAccent(MathedInset * p);
159     ///
160     int accent;
161         ///
162     int nestaccent[8];
163         ///
164     MathedTextCodes lastcode;
165
166  private:
167         ///
168     char macrobf[80];
169         ///
170     int macroln;
171         ///
172     MathFuncInset * imacro;
173 };
174
175
176 //--------------------   Inline Functions  -------------------------// 
177
178
179 #endif